
org.http4s.server.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4s-server_2.10 Show documentation
Show all versions of http4s-server_2.10 Show documentation
Base library for building http4s servers
package org.http4s
import scalaz.Kleisli
import scalaz.concurrent.Task
import scalaz.syntax.kleisli._
package object server {
/**
* A middleware is a function of one [[Service]] to another, possibly of a
* different [[Request]] and [[Response]] type. http4s comes with several
* middlewares for composing common functionality into services.
*
* @tparam A the request type of the original service
* @tparam B the response type of the original service
* @tparam C the request type of the resulting service
* @tparam D the response type of the original service
*/
type Middleware[A, B, C, D] = Service[A, B] => Service[C, D]
object Middleware {
def apply[A, B, C, D](f: (C, Service[A, B]) => Task[D]): Middleware[A, B, C, D] = {
service => Service.lift {
req => f(req, service)
}
}
}
/**
* An HTTP middleware converts an [[HttpService]] to another.
*/
type HttpMiddleware = Middleware[Request, Response, Request, Response]
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy