p

endpoints

algebra

package algebra

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait Assets extends Endpoints

    Describes endpoints related to static assets (e.g.

    Describes endpoints related to static assets (e.g. medias, scripts, stylesheets, etc.)

  2. trait BasicAuthentication extends Endpoints

    Provides vocabulary to describe endpoints that use Basic HTTP authentication.

    Provides vocabulary to describe endpoints that use Basic HTTP authentication.

    This trait works fine, but developers are likely to implement their own authentication mechanism, specific to their application.

  3. trait Decoder [-From, +To] extends AnyRef
  4. trait Encoder [-From, +To] extends AnyRef
  5. trait Endpoints extends Urls with Methods

    Algebra interface for describing endpoints made of requests and responses.

    Algebra interface for describing endpoints made of requests and responses.

    Requests and responses contain headers and entity.

    /**
      * Describes an HTTP endpoint whose:
      *  - request uses verb “GET”,
      *  - URL is made of path “/foo”,
      *  - response has no entity
      */
    val example = endpoint(get(path / "foo"), emptyResponse)
  6. trait JsonEntities extends Endpoints

    Algebra interface for describing JSON entities in requests and responses.

    Algebra interface for describing JSON entities in requests and responses.

    /**
      * Describes an HTTP endpoint whose:
      *  - request uses verb “GET”,
      *  - URL is made of the segment “/user” followed by a `String` segment,
      *  - response content type is JSON and contains a `User`
      */
    val example = endpoint(get(path / "user" / segment[UUID]), jsonResponse[User])
  7. trait LowLevelEndpoints extends Endpoints

    Provides a way to define endpoints that directly expose the low level APIs of the interpreters.

    Provides a way to define endpoints that directly expose the low level APIs of the interpreters.

    Using this trait is not recommended because endpoints defined using these methods miss the opportunity to share a consistent protocol between client and server interpreters. However, it can be useful for transitioning legacy code.

    Example of endpoint definition:

    val someEndpoint = endpoint(post(path, rawRequestEntity), rawResponseEntity)

    Endpoint implementation:

    someEndpoint.implementedBy { request =>
      Ok(request.body.asText.getOrElse("Unable to decode request entity"))
    }

    XMLHttpRequest call:

    someEndpoint(xhr => "Foo")
      .map(response => println(response.responseText))
  8. trait Methods extends AnyRef
  9. trait MuxRequest extends AnyRef

    Multiplexed request type

  10. trait OptionalResponses extends Endpoints

    /**
      * Describes an endpoint whose response ''might'' have an entity containing a `User`.
      */
    val example = endpoint(get(path / "user" / segment[UUID]), option(jsonResponse[User]))
  11. trait Urls extends AnyRef

    Algebra interface for describing URLs made of a path and a query string.

    Algebra interface for describing URLs made of a path and a query string.

    A path is itself made of segments chained together.

    A query string is made of named parameters.

    /**
      * Describes an URL starting with a segment containing “articles”, followed
      * by another `String` segment, and a query string containing
      * a mandatory `Lang` parameter named “lang”, and an
      * optional `Int` parameter named “page”.
      *
      * Examples of matching URLs:
      *
      * - /articles/kitchen?lang=fr
      * - /articles/garden?lang=en&page=2
      */
    val example = path / "articles" / segment[String] /? (qs[Lang]("lang") & optQs[Int]("page"))

Value Members

  1. object BasicAuthentication

Ungrouped