http4sScala 的 HTTP 服務(wù)接口
http4s 是一個小型的 Scala 接口,用于處理 HTTP 服務(wù)。相當于 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.")
}評論
圖片
表情
