HttpAppMiddleware

zio.http.HttpAppMiddleware$

Attributes

Graph
Supertypes
trait HeaderModifier[RequestHandlerMiddleware[Nothing, Any, Nothing, Any]]
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Type members

Classlikes

final class Allow(val unit: Unit) extends AnyVal

Attributes

Graph
Supertypes
class AnyVal
trait Matchable
class Any
final class AllowZIO(val unit: Unit) extends AnyVal

Attributes

Graph
Supertypes
class AnyVal
trait Matchable
class Any
trait Contextual[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Simple[UpperEnv, LowerErr]
trait Contextual[LowerEnv, UpperEnv, LowerErr, UpperErr]
trait Simple[UpperEnv, LowerErr]
final implicit class HttpAppMiddlewareSyntax[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr](val self: HttpAppMiddleware[LowerEnv, UpperEnv, LowerErr, UpperErr]) extends AnyVal

Attributes

Graph
Supertypes
class AnyVal
trait Matchable
class Any
trait Simple[-UpperEnv, +LowerErr] extends Contextual[Nothing, UpperEnv, LowerErr, Any]

Attributes

Graph
Supertypes
trait Contextual[Nothing, UpperEnv, LowerErr, Any]
class Object
trait Matchable
class Any

Types

type WithOut[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr, OutEnv0[_], OutErr0[_]] = Contextual[LowerEnv, UpperEnv, LowerErr, UpperErr] { type OutEnv = OutEnv0; type OutErr = OutErr0; }

Value members

Concrete methods

Creates a middleware which can allow or disallow access to an http based on the predicate

Creates a middleware which can allow or disallow access to an http based on the predicate

Attributes

Creates a middleware which can allow or disallow access to an http based on the predicate effect

Creates a middleware which can allow or disallow access to an http based on the predicate effect

Attributes

def identity: HttpAppMiddleware[Nothing, Any, Nothing, Any]

An empty middleware that doesn't do perform any operations on the provided Http and returns it as it is.

An empty middleware that doesn't do perform any operations on the provided Http and returns it as it is.

Attributes

Inherited methods

final def addCookie(cookie: Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Sets cookie in response headers

Sets cookie in response headers

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def addCookieZIO[R](cookie: ZIO[R, Nothing, Response])(implicit trace: Trace): RequestHandlerMiddleware[Nothing, R, Nothing, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def addHeader(name: CharSequence, value: CharSequence): A

Attributes

Inherited from:
HeaderModifier
final def addHeader(header: Header): A

Attributes

Inherited from:
HeaderModifier
final def addHeaders(headers: Headers): A

Attributes

Inherited from:
HeaderModifier
final def basicAuth(u: String, p: String): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware for basic authentication that checks if the credentials are same as the ones given

Creates a middleware for basic authentication that checks if the credentials are same as the ones given

Attributes

Inherited from:
Auth (hidden)
final def basicAuth(f: Credentials => Boolean): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware for basic authentication

Creates a middleware for basic authentication

Attributes

Inherited from:
Auth (hidden)
final def basicAuthZIO[R, E](f: Credentials => ZIO[R, E, Boolean])(implicit trace: Trace): RequestHandlerMiddleware[Nothing, R, E, Any]

Creates a middleware for basic authentication using an effectful verification function

Creates a middleware for basic authentication using an effectful verification function

Attributes

Inherited from:
Auth (hidden)
final def bearerAuth(f: String => Boolean): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware for bearer authentication that checks the token using the given function

Creates a middleware for bearer authentication that checks the token using the given function

Attributes

f:

function that validates the token string inside the Bearer Header

Inherited from:
Auth (hidden)
final def bearerAuthZIO[R, E](f: String => ZIO[R, E, Boolean])(implicit trace: Trace): RequestHandlerMiddleware[Nothing, R, E, Any]

Creates a middleware for bearer authentication that checks the token using the given effectful function

Creates a middleware for bearer authentication that checks the token using the given effectful function

Attributes

f:

function that effectfully validates the token string inside the Bearer Header

Inherited from:
Auth (hidden)
final def beautifyErrors: RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Beautify the error response.

Beautify the error response.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def cors(config: CorsConfig): HttpAppMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware for Cross-Origin Resource Sharing (CORS).

Creates a middleware for Cross-Origin Resource Sharing (CORS).

Attributes

See also:
Inherited from:
Cors (hidden)
final def customAuth(verify: Request => Boolean, responseHeaders: Headers, responseStatus: Status): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates an authentication middleware that only allows authenticated requests to be passed on to the app.

Creates an authentication middleware that only allows authenticated requests to be passed on to the app.

Attributes

Inherited from:
Auth (hidden)
final def customAuthProviding[R0, Context : Tag](provide: Request => Option[Context], responseHeaders: Headers, responseStatus: Status): WithOut[R0 & Context, Any, Nothing, Any, <none>, <none>]

Creates an authentication middleware that only allows authenticated requests to be passed on to the app, and provides a context to the request handlers.

Creates an authentication middleware that only allows authenticated requests to be passed on to the app, and provides a context to the request handlers.

Attributes

Inherited from:
Auth (hidden)
final def customAuthProvidingZIO[R0, R, E, Context : Tag](provide: Request => ZIO[R, E, Option[Context]], responseHeaders: Headers, responseStatus: Status): WithOut[R0 & R & Context, R, E, Any, <none>, <none>]

Creates an authentication middleware that only allows authenticated requests to be passed on to the app, and provides a context to the request handlers.

Creates an authentication middleware that only allows authenticated requests to be passed on to the app, and provides a context to the request handlers.

Attributes

Inherited from:
Auth (hidden)
final def customAuthZIO[R, E](verify: Request => ZIO[R, E, Boolean], responseHeaders: Headers, responseStatus: Status): RequestHandlerMiddleware[Nothing, R, E, Any]

Creates an authentication middleware that only allows authenticated requests to be passed on to the app using an effectful verification function.

Creates an authentication middleware that only allows authenticated requests to be passed on to the app using an effectful verification function.

Attributes

Inherited from:
Auth (hidden)
final def debug: RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Add log status, method, url and time taken from req to res

Add log status, method, url and time taken from req to res

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
def dropTrailingSlash(onlyIfNoQueryParams: Boolean): HttpAppMiddleware[Nothing, Any, Nothing, Any]

Removes the trailing slash from the path.

Removes the trailing slash from the path.

Attributes

Inherited from:
HttpRoutesMiddlewares (hidden)
def dropTrailingSlash: HttpAppMiddleware[Nothing, Any, Nothing, Any]

Attributes

Inherited from:
HttpRoutesMiddlewares (hidden)
final def ifHeaderThenElse[UpperEnv, LowerErr](condition: Headers => Boolean)(ifTrue: RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any], ifFalse: RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]): RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]

Logical operator to decide which middleware to select based on the header

Logical operator to decide which middleware to select based on the header

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def ifMethodThenElse[UpperEnv, LowerErr](condition: Method => Boolean)(ifTrue: RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any], ifFalse: RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]): RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]

Logical operator to decide which middleware to select based on the method.

Logical operator to decide which middleware to select based on the method.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def ifRequestThenElse[UpperEnv, LowerErr](condition: Request => Boolean)(ifTrue: RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any], ifFalse: RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]): RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]

Logical operator to decide which middleware to select based on the predicate.

Logical operator to decide which middleware to select based on the predicate.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def ifRequestThenElseFunction[UpperEnv, LowerErr](condition: Request => Boolean)(ifTrue: Request => RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any], ifFalse: Request => RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]): RequestHandlerMiddleware[Nothing, UpperEnv, LowerErr, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def ifRequestThenElseFunctionZIO[R, E](condition: Request => ZIO[R, E, Boolean])(ifTrue: Request => Simple[R, E], ifFalse: Request => Simple[R, E]): RequestHandlerMiddleware[Nothing, R, E, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def ifRequestThenElseZIO[R, E](condition: Request => ZIO[R, E, Boolean])(ifTrue: RequestHandlerMiddleware[Nothing, R, E, Any], ifFalse: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Logical operator to decide which middleware to select based on the predicate.

Logical operator to decide which middleware to select based on the predicate.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def intercept(fromRequestAndResponse: (Request, Response) => Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def interceptPatch[S](fromRequest: Request => S): InterceptPatch[S]

Creates a new middleware using transformation functions

Creates a new middleware using transformation functions

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def interceptPatchZIO[R, E, S](fromRequest: Request => ZIO[R, E, S]): InterceptPatchZIO[R, E, S]

Creates a new middleware using effectful transformation functions

Creates a new middleware using effectful transformation functions

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
def metrics(pathLabelMapper: PartialFunction[Request, String], concurrentRequestsName: String, totalRequestsName: String, requestDurationName: String, requestDurationBoundaries: Boundaries, extraLabels: Set[MetricLabel]): HttpAppMiddleware[Nothing, Any, Nothing, Any]

Adds metrics to a zio-http server.

Adds metrics to a zio-http server.

Attributes

extraLabels

A set of extra labels all metrics will be tagged with.

pathLabelMapper

A mapping function to map incoming paths to patterns, such as /users/1 to /users/:id.

requestDurationBoundaries

Boundaries for the HTTP request duration metric.

requestDurationName

HTTP request duration metric name.

totalRequestsName

Total HTTP requests metric name.

Note:

When using Prometheus as your metrics backend, make sure to provide a pathLabelMapper in order to avoid high cardinality labels.

Inherited from:
Metrics (hidden)
final def patch(f: Response => Patch): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware that produces a Patch for the Response

Creates a middleware that produces a Patch for the Response

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def patchZIO[R, E](f: Response => ZIO[R, E, Patch]): RequestHandlerMiddleware[Nothing, R, E, Any]

Creates a middleware that produces a Patch for the Response effectfully.

Creates a middleware that produces a Patch for the Response effectfully.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def redirect(url: URL, isPermanent: Boolean): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Client redirect temporary or permanent to specified url.

Client redirect temporary or permanent to specified url.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def redirectTrailingSlash(isPermanent: Boolean)(implicit trace: Trace): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Permanent redirect if the trailing slash is present in the request URL.

Permanent redirect if the trailing slash is present in the request URL.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def removeHeader(name: String): A

Attributes

Inherited from:
HeaderModifier
final def removeHeader(headerType: HeaderType): A

Attributes

Inherited from:
HeaderModifier
final def removeHeaders(headers: Set[String]): A

Attributes

Inherited from:
HeaderModifier
final def replace[R, E](newHandler: RequestHandler[R, E]): RequestHandlerMiddleware[Nothing, R, E, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
protected def replaceErrorResponse(request: Request, response: Response): Response

Attributes

Inherited from:
HtmlErrorResponses (hidden)
final def requestLogging(level: Status => LogLevel, failureLevel: LogLevel, loggedRequestHeaders: Set[HeaderType], loggedResponseHeaders: Set[HeaderType], logRequestBody: Boolean, logResponseBody: Boolean, requestCharset: Charset, responseCharset: Charset)(implicit trace: Trace): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Attributes

Inherited from:
RequestLogging (hidden)
final def runAfter[R](effect: ZIO[R, Nothing, Any])(implicit trace: Trace): RequestHandlerMiddleware[Nothing, R, Nothing, Any]

Runs the effect after the middleware is applied

Runs the effect after the middleware is applied

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def runBefore[R, E](effect: ZIO[R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Runs the effect before the request is passed on to the HttpApp on which the middleware is applied.

Runs the effect before the request is passed on to the HttpApp on which the middleware is applied.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def setHeaders(headers: Headers): A

Attributes

Inherited from:
HeaderModifier
final def signCookies(secret: String): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware for signing cookies

Creates a middleware for signing cookies

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def timeout(duration: Duration): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Times out the application with a 408 status code.

Times out the application with a 408 status code.

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final override def updateHeaders(update: Headers => Headers): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Updates the provided list of headers to the response

Updates the provided list of headers to the response

Attributes

Definition Classes
RequestHandlerMiddlewares -> HeaderModifier
Inherited from:
RequestHandlerMiddlewares (hidden)
final def updateResponse(f: Response => Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a middleware that updates the response produced

Creates a middleware that updates the response produced

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def updateResponseZIO[R](f: Response => ZIO[R, Nothing, Response]): RequestHandlerMiddleware[Nothing, R, Nothing, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def whenHeader[R, E](condition: Headers => Boolean)(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Applies the middleware only when the condition for the headers are true

Applies the middleware only when the condition for the headers are true

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def whenRequest[R, E](condition: Request => Boolean)(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Applies the middleware only if the condition function evaluates to true

Applies the middleware only if the condition function evaluates to true

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def whenRequestZIO[R, E](condition: Request => ZIO[R, E, Boolean])(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def whenResponse[R, E](condition: Response => Boolean)(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Applies the middleware only if the condition function evaluates to true

Applies the middleware only if the condition function evaluates to true

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def whenResponseZIO[R, E](condition: Response => ZIO[R, E, Boolean])(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Applies the middleware only if the condition function effectfully evaluates to true

Applies the middleware only if the condition function effectfully evaluates to true

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
final def whenStatus[R, E](condition: Status => Boolean)(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]

Applies the middleware only if status matches the condition

Applies the middleware only if status matches the condition

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)
def withHeader(header: Header): A

Attributes

Inherited from:
HeaderModifier
final def withStatus(status: Status): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

Creates a new middleware that always sets the response status to the provided value

Creates a new middleware that always sets the response status to the provided value

Attributes

Inherited from:
RequestHandlerMiddlewares (hidden)

Implicits

Implicits

final implicit def HttpAppMiddlewareSyntax[LowerEnv, UpperEnv, LowerErr, UpperErr](self: HttpAppMiddleware[LowerEnv, UpperEnv, LowerErr, UpperErr]): HttpAppMiddlewareSyntax[LowerEnv, UpperEnv, LowerErr, UpperErr]