trait Responses extends algebra.Responses with StatusCodes with Headers
Interpreter for algebra.Responses
- Self Type
- Responses with Errors
- Source
- Responses.scala
- Grouped
- Alphabetic
- By Inheritance
- Responses
- Headers
- StatusCodes
- Responses
- InvariantFunctorSyntax
- StatusCodes
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit class InvariantFunctorSyntax[A, F[_]] extends AnyRef
Extension methods for values of type
F[A]
for which there is an implicitInvariantFunctor[F]
instance.Extension methods for values of type
F[A]
for which there is an implicitInvariantFunctor[F]
instance.- Definition Classes
- InvariantFunctorSyntax
- implicit class ResponseSyntax[A] extends AnyRef
Extension methods for Response.
- case class DocumentedHeader(name: String, description: Option[String], required: Boolean, schema: Schema) extends Product with Serializable
- Definition Classes
- Headers
- case class DocumentedHeaders(value: List[DocumentedHeader]) extends Product with Serializable
- value
List of request header names (e.g. “Authorization”)
- Definition Classes
- Headers
- case class DocumentedResponse(status: (Responses.this)#StatusCode, documentation: String, headers: (Responses.this)#DocumentedHeaders, content: Map[String, MediaType]) extends Product with Serializable
- status
Response status code (e.g. OK or NotFound)
- documentation
Human readable documentation. Not optional because its required by openapi
- headers
Response headers documentation
- content
Map that associates each possible content-type (e.g. “text/html”) with a
MediaType
description
- type Response[A] = List[(Responses.this)#DocumentedResponse]
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.- Definition Classes
- Responses → Responses
- Note
This type has implicit methods provided by the InvariantFunctorSyntax and ResponseSyntax classes
- type ResponseEntity[A] = Map[String, MediaType]
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.
- Definition Classes
- Responses → Responses
- Note
This type has implicit methods provided by the InvariantFunctorSyntax class
- type ResponseHeaders[A] = (Responses.this)#DocumentedHeaders
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.- Definition Classes
- Responses → Responses
- Note
This type has implicit methods provided by the SemigroupalSyntax and InvariantFunctorSyntax classes.
- type StatusCode = Int
HTTP Status Code
HTTP Status Code
- Definition Classes
- StatusCodes → StatusCodes
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Responses, B)
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def Accepted: Int
- Definition Classes
- StatusCodes → StatusCodes
- def AlreadyReported: Int
- Definition Classes
- StatusCodes → StatusCodes
- def BadRequest: Int
- Definition Classes
- StatusCodes → 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.
- def Conflict: Int
- Definition Classes
- StatusCodes → StatusCodes
- def Created: Int
- Definition Classes
- StatusCodes → StatusCodes
- def ExpectationFailed: Int
- Definition Classes
- StatusCodes → StatusCodes
- def FailedDependency: Int
- Definition Classes
- StatusCodes → StatusCodes
- def Forbidden: Int
- Definition Classes
- StatusCodes → StatusCodes
- def Gone: Int
- Definition Classes
- StatusCodes → StatusCodes
- def IMUsed: Int
- Definition Classes
- StatusCodes → StatusCodes
- def InternalServerError: Int
- Definition Classes
- StatusCodes → 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.
- def LengthRequired: Int
- Definition Classes
- StatusCodes → StatusCodes
- def Locked: Int
- Definition Classes
- StatusCodes → StatusCodes
- def MethodNotAllowed: Int
- Definition Classes
- StatusCodes → StatusCodes
- def MisdirectedRequest: Int
- Definition Classes
- StatusCodes → StatusCodes
- def MultiStatus: Int
- Definition Classes
- StatusCodes → StatusCodes
- def NoContent: Int
- Definition Classes
- StatusCodes → StatusCodes
- def NonAuthoritativeInformation: Int
- Definition Classes
- StatusCodes → StatusCodes
- def NotAcceptable: Int
- Definition Classes
- StatusCodes → StatusCodes
- def NotFound: Int
- Definition Classes
- StatusCodes → StatusCodes
- def NotImplemented: Int
- Definition Classes
- StatusCodes → StatusCodes
- def NotModified: Int
- Definition Classes
- StatusCodes → StatusCodes
- def OK: Int
- Definition Classes
- StatusCodes → StatusCodes
- def PartialContent: Int
- Definition Classes
- StatusCodes → StatusCodes
- def PayloadTooLarge: Int
- Definition Classes
- StatusCodes → StatusCodes
- def PaymentRequired: Int
- Definition Classes
- StatusCodes → StatusCodes
- def PermanentRedirect: Int
- Definition Classes
- StatusCodes → StatusCodes
- def PreconditionFailed: Int
- Definition Classes
- StatusCodes → StatusCodes
- def PreconditionRequired: Int
- Definition Classes
- StatusCodes → StatusCodes
- def ProxyAuthenticationRequired: Int
- Definition Classes
- StatusCodes → StatusCodes
- def RangeNotSatisfiable: Int
- Definition Classes
- StatusCodes → StatusCodes
- def RequestHeaderFieldsTooLarge: Int
- Definition Classes
- StatusCodes → StatusCodes
- def RequestTimeout: Int
- Definition Classes
- StatusCodes → StatusCodes
- def ResetContent: Int
- Definition Classes
- StatusCodes → StatusCodes
- def TemporaryRedirect: Int
- Definition Classes
- StatusCodes → StatusCodes
- def TooEarly: Int
- Definition Classes
- StatusCodes → StatusCodes
- def TooManyRequests: Int
- Definition Classes
- StatusCodes → StatusCodes
- def Unauthorized: Int
- Definition Classes
- StatusCodes → StatusCodes
- def UnavailableForLegalReasons: Int
- Definition Classes
- StatusCodes → StatusCodes
- def UnprocessableEntity: Int
- Definition Classes
- StatusCodes → StatusCodes
- def UnsupportedMediaType: Int
- Definition Classes
- StatusCodes → StatusCodes
- def UpgradeRequired: Int
- Definition Classes
- StatusCodes → StatusCodes
- def UriTooLong: Int
- Definition Classes
- StatusCodes → StatusCodes
- def addResponseHeaders[A, H](response: (Responses.this)#Response[A], headers: (Responses.this)#ResponseHeaders[H])(implicit tupler: Tupler[A, H]): (Responses.this)#Response[Out]
Add the provided
headers
to theresponse
. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def badRequest[A, R](docs: Documentation = None, headers: (Responses.this)#ResponseHeaders[A] = emptyResponseHeaders)(implicit tupler: Tupler.Aux[(Responses.this)#ClientErrors, A, R]): (Responses.this)#Response[R]
Bad Request (400) response, with an entity of type
ClientErrors
.Bad Request (400) response, with an entity of type
ClientErrors
.- Definition Classes
- Responses
- See also
endpoints4s.algebra.Errors and endpoints4s.algebra.BuiltInErrors
- def choiceResponse[A, B](responseA: (Responses.this)#Response[A], responseB: (Responses.this)#Response[B]): (Responses.this)#Response[Either[A, B]]
Alternative between two possible choices of responses.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def emptyResponse: (Responses.this)#ResponseEntity[Unit]
Empty response entity
- def emptyResponseHeaders: (Responses.this)#ResponseHeaders[Unit]
No particular response header.
- def ensuring(cond: (Responses) => Boolean, msg: => Any): Responses
- def ensuring(cond: (Responses) => Boolean): Responses
- def ensuring(cond: Boolean, msg: => Any): Responses
- def ensuring(cond: Boolean): Responses
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def internalServerError[A, R](docs: Documentation = None, headers: (Responses.this)#ResponseHeaders[A] = emptyResponseHeaders)(implicit tupler: Tupler.Aux[(Responses.this)#ServerError, A, R]): (Responses.this)#Response[R]
Internal Server Error (500) response, with an entity of type
ServerError
.Internal Server Error (500) response, with an entity of type
ServerError
.- Definition Classes
- Responses
- See also
endpoints4s.algebra.Errors and endpoints4s.algebra.BuiltInErrors
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def ok[A, B, R](entity: (Responses.this)#ResponseEntity[A], docs: Documentation = None, headers: (Responses.this)#ResponseHeaders[B] = emptyResponseHeaders)(implicit tupler: Tupler.Aux[A, B, R]): (Responses.this)#Response[R]
OK (200) Response with the given entity
OK (200) Response with the given entity
- Definition Classes
- Responses
- def optResponseHeader(name: String, docs: Documentation = None): (Responses.this)#ResponseHeaders[Option[String]]
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]
, orNone
if the response header is missing. - Server interpreters should produce such a response header.
- Documentation interpreters should document this header.
- Client interpreters should model the header value as
- def response[A, B, R](statusCode: (Responses.this)#StatusCode, entity: (Responses.this)#ResponseEntity[A], docs: Documentation = None, headers: (Responses.this)#ResponseHeaders[B])(implicit tupler: Tupler.Aux[A, B, R]): (Responses.this)#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.
- statusCode
Response status code
- entity
Response entity
- docs
Response documentation
- headers
Response headers
- implicit lazy val responseEntityInvariantFunctor: InvariantFunctor[(Responses.this)#ResponseEntity]
- def responseHeader(name: String, docs: Documentation = None): (Responses.this)#ResponseHeaders[String]
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") ) )
- Client interpreters should model the header value as
- implicit def responseHeadersInvariantFunctor: InvariantFunctor[(Responses.this)#ResponseHeaders]
Provides
xmap
operation. - implicit def responseHeadersSemigroupal: Semigroupal[(Responses.this)#ResponseHeaders]
Provides
++
operation. - implicit lazy val responseInvariantFunctor: InvariantFunctor[(Responses.this)#Response]
Provides the operation
xmap
to the typeResponse
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def textResponse: (Responses.this)#ResponseEntity[String]
Text response entity
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wheneverFound[A](responseA: (Responses.this)#Response[A], notFoundDocs: Documentation = None): (Responses.this)#Response[Option[A]]
Turns a
Response[A]
into aResponse[Option[A]]
.Turns a
Response[A]
into aResponse[Option[A]]
.Interpreters represent
None
with an empty HTTP response whose status code is 404 (Not Found).- Definition Classes
- Responses
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Responses toStringFormat[Responses] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (Responses, B)
- Implicit
- This member is added by an implicit conversion from Responses toArrowAssoc[Responses] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
Inherited from Headers
Inherited from StatusCodes
Inherited from algebra.Responses
Inherited from endpoints4s.InvariantFunctorSyntax
Inherited from algebra.StatusCodes
Inherited from AnyRef
Inherited from Any
Types
Types introduced by the algebra
Operations
Operations creating and transforming values