c

org.http4s.dsl.impl

OptionalValidatingQueryParamDecoderMatcher

abstract class OptionalValidatingQueryParamDecoderMatcher[T] extends AnyRef

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 ValidatingQueryParamDecoderMatcher[Foo]("foo")
object BarMatcher extends OptionalValidatingQueryParamDecoderMatcher[Bar]("bar")

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  => { ... }
    )
Source
Path.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OptionalValidatingQueryParamDecoderMatcher
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OptionalValidatingQueryParamDecoderMatcher(name: String)(implicit arg0: QueryParamDecoder[T])

Value Members

  1. def unapply(params: Map[String, Seq[String]]): Some[Option[ValidatedNel[ParseFailure, T]]]