http4sScala 的 HTTP 服务接口
http4s 是一个小型的 Scala 接口,用于处理 HTTP 服务。相当于 Ruby 的 Rack、Python 的 WSGI、Haskell 的 WAI 和 Java 的 Servlet。
示例代码:
// Make your model safe and streaming by using a scalaz-stream Process
def getData(req: Request): Process[Task, String] = ???
val service: HttpService = {
// Wire your data into your service
case GET -> Root / "streaming" => Ok(getData(req))
// You can use helpers to send any type of data with an available Writable[T]
case GET -> Root / "synchronous" => Ok("This is good to go right now.")
}评论
