io.finch

route

package route

This package contains various of functions and types that enable _router combinators_ in Finch. A Finch Router is an abstraction that is responsible for routing the HTTP requests using their method and path information. There are two types of routers in Finch: Router0 and RouterN. Router0 matches the route and returns an Option of the rest of the route. RouterN[A] (or just Router[A]) in addition to the Router0 behaviour extracts a value of type A from the route.

A Router that maps route to a Service is called an Endpoint. An endpoint Req => Rep might be implicitly converted into a Service[Req, Rep]. Thus, the following example is a valid Finch code:

def hello(s: String) = new Service[HttRequest, HttpResponse] {
  def apply(req: HttpRequest) = Ok(s"Hello $name!").toFuture
}

Httpx.serve(
  new InetSocketAddress(8081),
  Get / string /> hello // will be implicitly converted into service
)
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. route
  2. LowPriorityRouterImplicits
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. case class /[+A, +B](_1: A, _2: B) extends Product with Serializable

    A case class that enables the following syntax:

    A case class that enables the following syntax:

    val r: Router[Int / String] = Get / int / string
    val s: String = p /> { case i / s => s + i }
  2. type Endpoint[-A, +B] = RouterN[Service[A, B]]

    An alias for Router that maps route to a Service.

  3. case class Extractor[A](name: String, f: (String) ⇒ Option[A]) extends RouterN[A] with Product with Serializable

    An universal extractor that extracts some value of type A if it's possible to fetch the value from the string.

  4. trait LowPriorityRouterImplicits extends AnyRef

  5. case class Matcher(s: String) extends Router0 with Product with Serializable

    An universal matcher.

  6. case class MethodMatcher(m: Method) extends Router0 with Product with Serializable

    A Router0 that matches the given HTTP method m in the route.

  7. implicit class RArrow1[A] extends AnyRef

    Add /> compositors to RouterN to compose it with function of one argument.

    Add /> compositors to RouterN to compose it with function of one argument.

    Definition Classes
    LowPriorityRouterImplicits
  8. implicit final class RArrow2[A, B] extends AnyVal

    Add /> compositor to RouterN to compose it with function of two argument.

  9. implicit final class RArrow3[A, B, C] extends AnyVal

    Add /> compositor to RouterN to compose it with function of three argument.

  10. implicit final class RArrow4[A, B, C, D] extends AnyVal

    Add /> compositor to RouterN to compose it with function of four argument.

  11. case class RouteNotFound(r: String) extends Exception with Product with Serializable

    An exception, which is thrown by router in case of missing route r.

  12. type Router[+A] = RouterN[A]

    A user friendly alias for RouterN.

  13. trait Router0 extends AnyRef

    A router that match the given route to some predicate.

  14. trait RouterN[+A] extends AnyRef

    A router that extracts some value of the type A from the given route.

Value Members

  1. object * extends Router0

    A Router0 that skips one route token.

  2. object ** extends Router0

    A Router0 that skips all route tokens.

  3. object Connect extends MethodMatcher

  4. object Delete extends MethodMatcher

  5. object Get extends MethodMatcher

  6. object Head extends MethodMatcher

  7. object Options extends MethodMatcher

  8. object Patch extends MethodMatcher

  9. object PathTokenExtractor extends RouterN[String]

    A RouterN that extracts a path token.

  10. object Post extends MethodMatcher

  11. object Put extends MethodMatcher

  12. object Trace extends MethodMatcher

  13. object boolean extends Extractor[Boolean]

    A RouterN that extract a boolean value from the route.

  14. implicit def booleanToMather(b: Boolean): Router0

  15. implicit def endpointToService[Req, Rep](r: RouterN[Service[Req, Rep]])(implicit ev: (Req) ⇒ HttpRequest): Service[Req, Rep]

    Implicitly converts the given Router[Service[_, _]] into a service.

  16. object int extends Extractor[Int]

    A RouterN that extract an integer from the route.

  17. implicit def intToMatcher(i: Int): Router0

  18. object long extends Extractor[Long]

    A RouterN that extract a long value from the route.

  19. object string extends Extractor[String]

    A RouterN that extract a string value from the route.

  20. implicit def stringToMatcher(s: String): Router0

  21. object tokens

Inherited from AnyRef

Inherited from Any

Ungrouped