ServerEndpoint

sttp.tapir.server.ServerEndpoint
See theServerEndpoint companion object
abstract class ServerEndpoint[-R, F[_]] extends EndpointInfoOps[R], EndpointMetaOps

An Endpoint together with functions implementing the endpoint's security and main logic.

Type parameters

F

The effect type constructor used in the provided server logic.

R

Requirements: The capabilities that are required by this endpoint's inputs/outputs. Any, if no requirements.

Attributes

Companion
object
Graph
Supertypes
trait EndpointInfoOps[R]
class Object
trait Matchable
class Any
Self type

Members list

Type members

Types

Error output parameter types (abbreviated as E).

Error output parameter types (abbreviated as E).

Attributes

type INPUT

Input parameter types (abbreviated as I).

Input parameter types (abbreviated as I).

Attributes

type OUTPUT

Output parameter types (abbreviated as O).

Output parameter types (abbreviated as O).

Attributes

type PRINCIPAL

The type of the value returned by the security logic, e.g. a user (abbreviated as U).

The type of the value returned by the security logic, e.g. a user (abbreviated as U).

Attributes

Security input parameter types (abbreviated as A).

Security input parameter types (abbreviated as A).

Attributes

override type ThisType[-_R] = Full[SECURITY_INPUT, PRINCIPAL, INPUT, ERROR_OUTPUT, OUTPUT, _R, F]

Value members

Abstract methods

def logic: (MonadError[F]) => PRINCIPAL => INPUT => F[Either[ERROR_OUTPUT, OUTPUT]]
def securityLogic: (MonadError[F]) => SECURITY_INPUT => F[Either[ERROR_OUTPUT, PRINCIPAL]]

Concrete methods

Attributes

Definition Classes
override def info: EndpointInfo

Attributes

Definition Classes
override def input: EndpointInput[INPUT]

Attributes

Definition Classes
override def output: EndpointOutput[OUTPUT]

Attributes

Definition Classes
def prependSecurity[A2, E2 : ErasureSameAsType](additionalSecurityInput: EndpointInput[A2], securityErrorOutput: EndpointOutput[E2])(additionalSecurityLogic: A2 => F[Either[E2, Unit]]): ServerEndpoint[R, F]

Prepends additional security logic to this endpoint. This is useful when adding security to file/resource-serving endpoints. The additional security logic should return a Right(()) to indicate success, or a Left(E2) to indicate failure; in this case, the given error output will be used to create the response.

Prepends additional security logic to this endpoint. This is useful when adding security to file/resource-serving endpoints. The additional security logic should return a Right(()) to indicate success, or a Left(E2) to indicate failure; in this case, the given error output will be used to create the response.

The security inputs will become a tuple, containing first additionalSecurityInput combined with the current endpoint.securityInput.

The error output will consist of two variants: either the securityErrorOutput (the ClassTag requirement for E2 is used to create the oneOfVariant). In the absence of sum types, the resulting errors are typed as Any.

The security logic is modified so that first additionalSecurityLogic is run, followed by the security logic defined so far.

The type of the value returned by the combined security logic, or the regular logic remains unchanged.

Type parameters

A2

Type of the additional security input.

E2

Type of the error output for the security logic.

Attributes

def prependSecurityIn(additionalInput: EndpointInput[Unit]): ServerEndpoint[R, F]

Prepends an additional input to this endpoint. This is useful when adding a context path to endpoints, e.g. serverEndpoint.prependSecurityIn("api" / "v1").

Prepends an additional input to this endpoint. This is useful when adding a context path to endpoints, e.g. serverEndpoint.prependSecurityIn("api" / "v1").

The given input can't map to any values in the request, hence its type is EndpointInput[Unit]; it has to be "netural" so that the server logic function can remain unchanged.

The input is prepended to the security inputs, so that it is decoded before any other path-related inputs (either security or regular).

Attributes

def prependSecurityPure[A2, E2 : ErasureSameAsType](additionalSecurityInput: EndpointInput[A2], securityErrorOutput: EndpointOutput[E2])(additionalSecurityLogic: A2 => Either[E2, Unit]): ServerEndpoint[R, F]

Attributes

Attributes

Definition Classes

Inherited methods

def attribute[T](k: AttributeKey[T], v: T): ThisType[R]

Attributes

Inherited from:
EndpointInfoOps
def attribute[T](k: AttributeKey[T]): Option[T]

Attributes

Inherited from:
EndpointInfoOps
def deprecated(): ThisType[R]

Attributes

Inherited from:
EndpointInfoOps
def description(d: String): ThisType[R]

Attributes

Inherited from:
EndpointInfoOps
def info(i: EndpointInfo): ThisType[R]

Attributes

Inherited from:
EndpointInfoOps
def name(n: String): ThisType[R]

Attributes

Inherited from:
EndpointInfoOps
def showPathTemplate(showPathParam: (Int, PathCapture[_]) => String, showQueryParam: Option[(Int, Query[_]) => String], includeAuth: Boolean, showNoPathAs: String, showPathsAs: Option[String], showQueryParamsAs: Option[String]): String

Shows endpoint path, by default all parametrised path and query components are replaced by {param_name} or {paramN}, e.g. for

Shows endpoint path, by default all parametrised path and query components are replaced by {param_name} or {paramN}, e.g. for

endpoint.in("p1" / path[String] / query[String]("par2"))

returns /p1/{param1}?par2={par2}

Value parameters

includeAuth

Should authentication inputs be included in the result.

showNoPathAs

How to show the path if the endpoint does not define any path inputs.

showPathsAs

How to show Tapir.paths inputs (if at all), which capture multiple paths segments

showQueryParamsAs

How to show Tapir.queryParams inputs (if at all), which capture multiple query parameters

Attributes

Inherited from:
EndpointMetaOps
def showRaw: String

Equivalent to .toString, shows the whole case class structure.

Equivalent to .toString, shows the whole case class structure.

Attributes

Inherited from:
EndpointMetaOps
def summary(s: String): ThisType[R]

Attributes

Inherited from:
EndpointInfoOps
def tag(t: String): ThisType[R]

Append t to the existing tags.

Append t to the existing tags.

Attributes

Inherited from:
EndpointInfoOps
def tags(ts: List[String]): ThisType[R]

Append ts to the existing tags.

Append ts to the existing tags.

Attributes

Inherited from:
EndpointInfoOps
def withTag(t: String): ThisType[R]

Overwrite the existing tags with a single tag t.

Overwrite the existing tags with a single tag t.

Attributes

Inherited from:
EndpointInfoOps
def withTags(ts: List[String]): ThisType[R]

Overwrite the existing tags with ts.

Overwrite the existing tags with ts.

Attributes

Inherited from:
EndpointInfoOps

Remove all tags from this endpoint.

Remove all tags from this endpoint.

Attributes

Inherited from:
EndpointInfoOps

Inherited fields

lazy val method: Option[Method]

The method defined in a fixed method input in this endpoint, if any (using e.g. EndpointInputsOps.get or EndpointInputsOps.post).

The method defined in a fixed method input in this endpoint, if any (using e.g. EndpointInputsOps.get or EndpointInputsOps.post).

Attributes

Inherited from:
EndpointMetaOps
lazy val show: String

Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.). E.g.: POST /books /add {header Authorization} {body as application/json (UTF-8)} -> {body as text/plain (UTF-8)}/-

Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.). E.g.: POST /books /add {header Authorization} {body as application/json (UTF-8)} -> {body as text/plain (UTF-8)}/-

Attributes

Inherited from:
EndpointMetaOps
lazy val showDetail: String

Detailed description of the endpoint, with inputs/outputs represented in the same order as originally defined, including mapping information. E.g.:

Detailed description of the endpoint, with inputs/outputs represented in the same order as originally defined, including mapping information. E.g.:

Endpoint(securityin: -, in: /books POST /add {body as application/json (UTF-8)} {header Authorization}, errout: {body as text/plain (UTF-8)}, out: -)

Attributes

Inherited from:
EndpointMetaOps
lazy val showShort: String

Shortened information about the endpoint. If the endpoint is named, returns the name, e.g. [my endpoint]. Otherwise, returns the string representation of the method (if any) and path, e.g. POST /books/add

Shortened information about the endpoint. If the endpoint is named, returns the name, e.g. [my endpoint]. Otherwise, returns the string representation of the method (if any) and path, e.g. POST /books/add

Attributes

Inherited from:
EndpointMetaOps