endpoints4s.algebra
Algebra interfaces
Attributes
Members list
Type members
Classlikes
Describes endpoints related to static assets (e.g. medias, scripts, stylesheets, etc.)
Describes endpoints related to static assets (e.g. medias, scripts, stylesheets, etc.)
Attributes
- Supertypes
-
trait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
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.
Attributes
- Companion
- object
- Supertypes
-
trait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
BasicAuthentication.type
Interpreter for the Errors algebra that uses endpoints4s built-in error types:
Algebra interface for describing request and response entities that use the chunked transfer-encoding.
Algebra interface for describing request and response entities that use the chunked transfer-encoding.
It introduces a type Chunks[A]
, which models a stream of chunks of type A
. It also introduces constructors for chunked request and response entities.
Chunk re-framing can happen during transport and is dependant on the specific implementation. It is known that browser clients re-frame chunks received from the server.
Example:
val notifications: Endpoint[Unit, Chunks[String]] =
endpoint(
get(path / "notifications"),
ok(textChunksResponse)
)
Or also:
val upload: Endpoint[Chunks[Array[Byte]], Unit] =
endpoint(
post(path / "upload", bytesChunksRequest),
ok(emptyResponse)
)
Attributes
- Supertypes
-
trait ChunkedResponseEntitiestrait ChunkedRequestEntitiestrait Chunkstrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait ChunkedJsonEntities
Enriches the ChunkedEntities algebra with constructors of request and response entities carrying JSON documents.
Enriches the ChunkedEntities algebra with constructors of request and response entities carrying JSON documents.
Example:
val events =
endpoint(
get(path / "events"),
ok(jsonChunksResponse[Event])
)
Attributes
- Supertypes
-
trait Framingtrait JsonCodecstrait JsonEntitiestrait ChunkedEntitiestrait ChunkedResponseEntitiestrait ChunkedRequestEntitiestrait Chunkstrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Framingtrait JsonCodecstrait JsonEntitiestrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxtrait ChunkedRequestEntitiestrait Chunksclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait ChunkedJsonEntities
Attributes
- Supertypes
-
trait Framingtrait JsonCodecstrait JsonEntitiestrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxtrait ChunkedResponseEntitiestrait Chunksclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait ChunkedJsonEntities
Attributes
- Supertypes
- Known subtypes
- Self type
Attributes
- Supertypes
- Known subtypes
- Self type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait ChunkedRequestEntitiestrait ChunkedEntitiestrait ChunkedJsonEntitiestrait ChunkedResponseEntitiesShow all
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)
This trait uses BuiltInErrors to model client and server errors.
Attributes
- Supertypes
-
trait BuiltInErrorstrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
Algebra interface for describing endpoints made of requests and responses.
Algebra interface for describing endpoints made of requests and responses.
Attributes
- Supertypes
-
trait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait Endpointstrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all
Defines the error types used to model client and server errors.
Defines the error types used to model client and server errors.
The ClientErrors
type is used by endpoints4s to model errors coming from the client (missing query parameter, invalid entity, etc.).
The ServerError
type is used by endpoints4s to model errors coming from the server business logic.
The badRequest
and internalServerError
operations defined in Responses define responses carrying entities of type ClientErrors
and ServerError
, respectively.
Interpreters are expected to use the clientErrorsResponse
and serverErrorResponse
operations defined here to handle client and server errors, respectively.
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait BuiltInErrorstrait Endpointstrait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all
- Self type
Attributes
- See also
- Companion
- object
- Supertypes
-
trait Serializableclass Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Algebra interface for describing how chunks of chunked transfer-encoding requests and responses should be framed. Being explicit about how chunks are framed solves the issue of re-framing happening during transport.
Algebra interface for describing how chunks of chunked transfer-encoding requests and responses should be framed. Being explicit about how chunks are framed solves the issue of re-framing happening during transport.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Fixes both the JsonRequest
and JsonResponse
types to be a same JsonCodec
type.
Fixes both the JsonRequest
and JsonResponse
types to be a same JsonCodec
type.
This trait is used as an implementation detail (to reuse code between JsonEntitiesFromSchemas and JsonEntitiesFromCodecs) and is not useful to end-users.
Attributes
- Supertypes
-
trait JsonEntitiestrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
- Known subtypes
Algebra interface for describing JSON entities in requests and responses.
Algebra interface for describing JSON entities in requests and responses.
Generally, this algebra is not directly used, but one of its specialized algebras is used instead: JsonEntitiesFromSchemas or JsonEntitiesFromCodecs.
/**
* 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])
Attributes
- Supertypes
-
trait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait JsonCodecstrait ChunkedJsonEntitiestrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemasShow all
Turns a JsonCodec
into a Codec.
Turns a JsonCodec
into a Codec.
Attributes
- Supertypes
-
trait JsonCodecstrait JsonEntitiestrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
Partially applies the JsonEntities algebra interface to fix the JsonRequest
and JsonResponse
types to be JsonSchema
.
Partially applies the JsonEntities algebra interface to fix the JsonRequest
and JsonResponse
types to be JsonSchema
.
Attributes
- Supertypes
-
trait JsonSchemastrait TuplesSchemastrait JsonCodecstrait JsonEntitiestrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
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))
Attributes
- Supertypes
-
trait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait Requeststrait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait Endpointstrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all
Algebra interface for describing endpoints such that one endpoint can handle several types of requests and responses.
Algebra interface for describing endpoints such that one endpoint can handle several types of requests and responses.
Attributes
- Supertypes
-
trait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
Multiplexed request type
Multiplexed request type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
trait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait Endpointstrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all
Attributes
- Supertypes
- Known subtypes
-
trait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait Endpointstrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all
- Self type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait Responsestrait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait Endpointstrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all
Attributes
- See also
- Companion
- object
- Supertypes
-
trait Serializableclass Objecttrait Matchableclass Any
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") & qs[Option[Int]]("page"))
Attributes
- Supertypes
- Known subtypes
-
trait Requeststrait Assetstrait BasicAuthenticationtrait ChunkedEntitiestrait ChunkedJsonEntitiestrait Endpointstrait JsonEntitiestrait JsonCodecstrait JsonEntitiesFromCodecstrait JsonEntitiesFromSchemastrait LowLevelEndpointstrait MuxEndpointsShow all