Responses

class Object
trait Matchable
class Any

Type members

Classlikes

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

Extension methods for Response.

Extension methods for Response.

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.

Inherited from:
InvariantFunctorSyntax

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.

Note:

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

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.

Note:

This type has implicit methods provided by the InvariantFunctorSyntax class

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.

Note:

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

Inherited types

HTTP Status Code

HTTP Status Code

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.

Empty response entity

Empty response entity

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

No particular response header.

No particular response header.

  • Client interpreters should ignore information carried by response headers.

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.
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

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")
     )
   )

Text response entity

Text response entity

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

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.

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.

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.

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

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).

Inherited methods

Inherited from:
StatusCodes
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
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes
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
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes
Inherited from:
StatusCodes

Implicits

Implicits

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

Extension methods for Response.

Extension methods for Response.

Provides xmap operation.

Provides xmap operation.

See also:

InvariantFunctorSyntax

Provides ++ operation.

Provides ++ operation.

See also:

Provides the operation xmap to the type Response

Provides the operation xmap to the type Response

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.

Inherited from:
InvariantFunctorSyntax