org.http4s.dsl.impl

Type members

Classlikes

object +&

Multiple param extractor: {{{ object A extends QueryParamDecoderMatcherString object B extends QueryParamDecoderMatcherInt val routes = HttpRoutes.of { case GET -> Root / "user" :? A(a) +& B(b) => ... }}}

object ->
object /
object /:

Path separator extractor: {{{ Path("/1/2/3/test.json") match { case "1" /: "2" /: _ => ... }}}

object :?
trait AllowResponseGenerator[F[_], G[_]] extends ResponseGenerator

Helper for the generation of a org.http4s.Response which must contain an Allow header and may contain a body.

A 405 status MUST contain an Allow header, which distinguishes this from other ResponseGenerators.

trait Auth
trait EmptyResponseGenerator[F[_], G[_]] extends ResponseGenerator

Helper for the generation of a org.http4s.Response which will not contain a body

While it is possible to for the org.http4s.Response manually, the EntityResponseGenerators offer shortcut syntax to make intention clear and concise.

Example

{{{ val resp: F[Response] = Status.Continue() }}}

trait EntityResponseGenerator[F[_], G[_]] extends ResponseGenerator

Helper for the generation of a org.http4s.Response which may contain a body

While it is possible to construct the org.http4s.Response manually, the EntityResponseGenerators offer shortcut syntax to make intention clear and concise.

Example

{{{ val resp: IO[Response] = Ok("Hello world!") }}}

abstract class FlagQueryParamMatcher(name: String)

Flag (value-less) query param extractor

object IntVar extends PathVar[Int]

Integer extractor of a path variable: {{{ Path("/user/123") match { case Root / "user" / IntVar(userId) => ... }}}

trait LocationResponseGenerator[F[_], G[_]] extends EntityResponseGenerator[F, G]

Helper for the generation of a org.http4s.Response which may contain a Location header and may contain a body.

A 300, 301, 302, 303, 307 and 308 status SHOULD contain a Location header, which distinguishes this from other EntityResponseGenerators.

object LongVar extends PathVar[Long]

Long extractor of a path variable: {{{ Path("/user/123") match { case Root / "user" / LongVar(userId) => ... }}}

abstract class MatrixVar[F[_]](name: String, domain: F[String])(`evidence$1`: Foldable[F])

Matrix path variable extractor For an example see MatrixURIs This is useful for representing a resource that may be addressed in multiple dimensions where order is unimportant

{{{

object BoardVar extends MatrixVar("square", List("x", "y")) Path("/board/square;x=5;y=3") match { case Root / "board" / BoardVar(IntVar(x), IntVar(y)) => ... } }}}

Companion
object
object MatrixVar
Companion
class
class MethodConcat(val methods: Set[Method])
trait Methods
abstract class OptionalMultiQueryParamDecoderMatcher[T](name: String)(`evidence$6`: QueryParamDecoder[T])

Capture a query parameter that appears 0 or more times.

{{{ case class Foo(i: Int) implicit val fooDecoder: QueryParamDecoder[Foo] = ... implicit val fooParam: QueryParam[Foo] = ...

object FooMatcher extends OptionalMultiQueryParamDecoderMatcherFoo val routes = HttpRoutes.of { // matches http://.../closest?foo=2&foo=3&foo=4 case GET -> Root / "closest" :? FooMatcher(Validated.Valid(Seq(Foo(2),Foo(3),Foo(4)))) => ...

/* * matches http://.../closest?foo=2&foo=3&foo=4 as well as http://.../closest (no parameters) * or http://.../closest?foo=2 (single occurrence) */ case GET -> Root / "closest" :? FooMatcher(is) => ... }}}

abstract class OptionalQueryParamDecoderMatcher[T](name: String)(`evidence$5`: QueryParamDecoder[T])
abstract class OptionalValidatingQueryParamDecoderMatcher[T](name: String)(`evidence$10`: QueryParamDecoder[T])

param extractor using org.http4s.QueryParamDecoder. Note that this will always match, but will return an Option possibly containing the result of the conversion to T

{{{ case class Foo(i: Int) implicit val fooDecoder: QueryParamDecoder[Foo] = ...

case class Bar(i: Int) implicit val barDecoder: QueryParamDecoder[Bar] = ...

object FooMatcher extends ValidatingQueryParamDecoderMatcherFoo object BarMatcher extends OptionalValidatingQueryParamDecoderMatcherBar

val routes = HttpRoutes.of { case GET -> Root / "closest" :? FooMatcher(fooValue) +& BarMatcher(barValue) => ^(fooValue, barValue getOrElse 42.right) { (foo, bar) => ... }.fold( nelE => BadRequest(nelE.toList.map(_.sanitized).mkString("\n")), baz => { ... } ) }}}

Helper for the generation of a org.http4s.Response which must contain a Proxy-Authenticate header and may contain a body.

A 407 status MUST contain a Proxy-Authenticate header, which distinguishes this from other EntityResponseGenerators.

abstract class QueryParamDecoderMatcher[T](name: String)(`evidence$2`: QueryParamDecoder[T])

param extractor using QueryParamDecoder: {{{ case class Foo(i: Int) implicit val fooDecoder: QueryParamDecoder[Foo] = ...

object FooMatcher extends QueryParamDecoderMatcherFoo val routes = HttpRoutes.of { case GET -> Root / "closest" :? FooMatcher(2) => ... }}}

abstract class QueryParamMatcher[T] extends QueryParamDecoderMatcher[T]

param extractor using QueryParamDecoder:

{{{ case class Foo(i: Int) implicit val fooDecoder: QueryParamDecoder[Foo] = ... implicit val fooParam: QueryParam[Foo] = ...

object FooMatcher extends QueryParamDecoderMatcher[Foo] val routes = HttpRoutes.of { case GET -> Root / "closest" :? FooMatcher(2) => ... }}}

trait Responses[F[_], G[_]]
Companion
object
object Responses
Companion
class
trait Statuses
object UUIDVar extends PathVar[UUID]

UUID extractor of a path variable: {{{ Path("/user/13251d88-7a73-4fcf-b935-54dfae9f023e") match { case Root / "user" / UUIDVar(userId) => ... }}}

abstract class ValidatingQueryParamDecoderMatcher[T](name: String)(`evidence$9`: QueryParamDecoder[T])

param extractor using org.http4s.QueryParamDecoder. Note that this will return a ParseFailure if the parameter cannot be decoded.

{{{ case class Foo(i: Int) implicit val fooDecoder: QueryParamDecoder[Foo] = ...

object FooMatcher extends ValidatingQueryParamDecoderMatcherFoo val routes: HttpRoutes.of = { case GET -> Root / "closest" :? FooMatcher(fooValue) => fooValue.fold( nelE => BadRequest(nelE.toList.map(_.sanitized).mkString("\n")), foo => { ... } ) }}}

Helper for the generation of a org.http4s.Response which must contain a WWW-Authenticate header and may contain a body.

A 401 status MUST contain a WWW-Authenticate header, which distinguishes this from other ResponseGenerators.

object ~

File extension extractor