Responses

endpoints4s.algebra.Responses

Attributes

Graph
Supertypes
trait StatusCodes
class Object
trait Matchable
class Any
Known subtypes
Self type

Members list

Type members

Classlikes

implicit class ResponseSyntax[A](response: Response[A])

Extension methods for Response.

Extension methods for Response.

Attributes

Supertypes
class Object
trait Matchable
class Any

Inherited classlikes

implicit class InvariantFunctorSyntax[A, F[_]](val fa: F[A])(implicit ev: InvariantFunctor[F])

Extension methods for values of type F[A] for which there is an implicit InvariantFunctor[F] instance.

Extension methods for values of type F[A] for which there is an implicit InvariantFunctor[F] instance.

Attributes

Inherited from:
InvariantFunctorSyntax
Supertypes
class Object
trait Matchable
class Any

Types

type Response[A]

An HTTP response (status, headers, and entity) carrying an information of type A

An HTTP response (status, headers, and entity) carrying an information of type A

Values of type Response[A] can be constructed by using the operations ok, badRequest, internalServerError, or the more general operation response.

Attributes

Note

This type has implicit methods provided by the InvariantFunctorSyntax and ResponseSyntax classes

type ResponseEntity[A]

An HTTP response entity carrying an information of type A

An HTTP response entity carrying an information of type A

Values of type ResponseEntity can be constructed by using the operations emptyResponse or textResponse. Additional types of response entities are provided by other algebra modules, such as JsonEntities or ChunkedEntities.

Attributes

Note

This type has implicit methods provided by the InvariantFunctorSyntax class

type ResponseHeaders[A]

Information carried by responses’ headers.

Information carried by responses’ headers.

You can construct values of type ResponseHeaders by using the operations responseHeader, optResponseHeader, or emptyResponseHeaders.

Attributes

Note

This type has implicit methods provided by the SemigroupalSyntax and InvariantFunctorSyntax classes.

Inherited types

type StatusCode

HTTP Status Code

HTTP Status Code

Attributes

Inherited from:
StatusCodes

Value members

Abstract methods

def choiceResponse[A, B](responseA: Response[A], responseB: Response[B]): Response[Either[A, B]]

Alternative between two possible choices of responses.

Alternative between two possible choices of responses.

Server interpreters construct either one or the other response. Client interpreters accept either one or the other response. Documentation interpreters list all the possible responses.

Attributes

Empty response entity

Empty response entity

  • Server interpreters produce no response entity,
  • Client interpreters ignore the response entity.

Attributes

No particular response header.

No particular response header.

  • Client interpreters should ignore information carried by response headers.

Attributes

Response headers optionally containing a header with the given name.

Response headers optionally containing a header with the given name.

  • Client interpreters should model the header value as Some[String], or None if the response header is missing.
  • Server interpreters should produce such a response header.
  • Documentation interpreters should document this header.

Attributes

def response[A, B, R](statusCode: StatusCode, entity: ResponseEntity[A], docs: Documentation, headers: ResponseHeaders[B])(implicit tupler: Aux[A, B, R]): Response[R]

Define an HTTP response

Define an HTTP response

  • Server interpreters construct a response with the given status and entity.
  • Client interpreters accept a response only if it has a corresponding status code.

Value parameters

docs

Response documentation

entity

Response entity

headers

Response headers

statusCode

Response status code

Attributes

Response headers containing a header with the given name.

Response headers containing a header with the given name.

  • Client interpreters should model the header value as String, or fail if the response header is missing.
  • Server interpreters should produce such a response header.
  • Documentation interpreters should document this header.

Example:

 val versionedResource: Endpoint[Unit, (SomeResource, String)] =
   endpoint(
     get(path / "versioned-resource"),
     ok(
       jsonResponse[SomeResource],
       headers = responseHeader("ETag")
     )
   )

Attributes

Text response entity

Text response entity

  • Server interpreters produce an HTTP response with a text/plain content type.

Attributes

Concrete methods

def addResponseHeaders[A, H](response: Response[A], headers: ResponseHeaders[H])(implicit tupler: Tupler[A, H]): Response[Out]

Add the provided headers to the response.

Add the provided headers to the response.

Note that if the response describes a choice of several possible responses (resulting from the orElse operation), the headers will be added to all the possible responses.

Attributes

final def badRequest[A, R](docs: Documentation, headers: ResponseHeaders[A])(implicit tupler: Aux[<none>, A, R]): Response[R]

Bad Request (400) response, with an entity of type ClientErrors.

Bad Request (400) response, with an entity of type ClientErrors.

Attributes

See also
final def internalServerError[A, R](docs: Documentation, headers: ResponseHeaders[A])(implicit tupler: Aux[<none>, A, R]): Response[R]

Internal Server Error (500) response, with an entity of type ServerError.

Internal Server Error (500) response, with an entity of type ServerError.

Attributes

See also
final def ok[A, B, R](entity: ResponseEntity[A], docs: Documentation, headers: ResponseHeaders[B])(implicit tupler: Aux[A, B, R]): Response[R]

OK (200) Response with the given entity

OK (200) Response with the given entity

Attributes

final def wheneverFound[A](responseA: Response[A], notFoundDocs: Documentation): Response[Option[A]]

Turns a Response[A] into a Response[Option[A]].

Turns a Response[A] into a Response[Option[A]].

Interpreters represent None with an empty HTTP response whose status code is 404 (Not Found).

Attributes

Inherited methods

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Note

You should use the badRequest constructor provided by the endpoints4s.algebra.Responses trait to ensure that errors produced by endpoints4s are consistently handled by interpreters.

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Note

You should use the internalServerError constructor provided by the endpoints4s.algebra.Responses trait to ensure that errors produced by endpoints4s are consistently handled by interpreters.

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes
def OK: StatusCode

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Attributes

Inherited from:
StatusCodes

Implicits

Implicits

final implicit def ResponseSyntax[A](response: Response[A]): ResponseSyntax[A]

Extension methods for Response.

Extension methods for Response.

Attributes

Provides xmap operation.

Provides xmap operation.

Attributes

See also

InvariantFunctorSyntax

Provides ++ operation.

Provides ++ operation.

Attributes

See also

Provides the operation xmap to the type Response

Provides the operation xmap to the type Response

Attributes

See also

InvariantFunctorSyntax

Inherited implicits

final implicit def InvariantFunctorSyntax[A, F[_]](fa: F[A])(implicit ev: InvariantFunctor[F]): InvariantFunctorSyntax[A, F]

Extension methods for values of type F[A] for which there is an implicit InvariantFunctor[F] instance.

Extension methods for values of type F[A] for which there is an implicit InvariantFunctor[F] instance.

Attributes

Inherited from:
InvariantFunctorSyntax