msg) + hello + } } @cask.get("/") - defhello= { + defhello(errorOpt:Opt。用Scala实现简单的Web和API服务器(16)。" />

用Scala实现简单的Web和API服务器(16)

+ elseif(msg.length >= 160) hello(Some("Message cannot be longer than 160 characters"))

+ else{

+ messages = messages :+(name -> msg)

+ hello

+ }

}

@cask.get("/")

- defhello= {

+ defhello(errorOpt:Option[String] = None)= {

html(

hr,

+ for(error= 10) hello(Some("Name cannot be longer than 10 characters"))

- elseif(msg == "") hello(Some("Message cannot be empty"))

- elseif(msg.length >= 160) hello(Some("Message cannot be longer than 160 characters"))

+ if(name == "") hello(Some("Name cannot be empty"), Some(name), Some(msg))

推荐阅读