object HttpAppMiddleware extends RequestHandlerMiddlewares with HttpRoutesMiddlewares
- Alphabetic
- By Inheritance
- HttpAppMiddleware
- HttpRoutesMiddlewares
- Cors
- RequestHandlerMiddlewares
- HtmlErrorResponses
- HeaderModifier
- Auth
- Metrics
- RequestLogging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final class Allow extends AnyVal
- final class AllowZIO extends AnyVal
- trait Contextual[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr] extends AnyRef
- implicit final class HttpAppMiddlewareSyntax[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr] extends AnyVal
- trait Simple[-UpperEnv, +LowerErr] extends Contextual[Nothing, UpperEnv, LowerErr, Any]
- type WithOut[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr, OutEnv0[_], OutErr0[_]] = Contextual[LowerEnv, UpperEnv, LowerErr, UpperErr] { ... /* 2 definitions in type refinement */ }
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def addCookie(cookie: Cookie.Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
Sets cookie in response headers
Sets cookie in response headers
- Definition Classes
- RequestHandlerMiddlewares
- final def addCookieZIO[R](cookie: ZIO[R, Nothing, Cookie.Response])(implicit trace: Trace): RequestHandlerMiddleware[Nothing, R, Nothing, Any]
- Definition Classes
- RequestHandlerMiddlewares
- final def addHeader(name: CharSequence, value: CharSequence): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- final def addHeader(header: Header): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- final def addHeaders(headers: Headers): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- def allow: Allow
Creates a middleware which can allow or disallow access to an http based on the predicate
- def allowZIO: AllowZIO
Creates a middleware which can allow or disallow access to an http based on the predicate effect
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- 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
- Definition Classes
- Auth
- final def basicAuth(f: (Credentials) => Boolean): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
Creates a middleware for basic authentication
Creates a middleware for basic authentication
- Definition Classes
- Auth
- 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
- Definition Classes
- Auth
- 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
- Definition Classes
- Auth
- 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
- Definition Classes
- Auth
- final def beautifyErrors: RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
Beautify the error response.
Beautify the error response.
- Definition Classes
- RequestHandlerMiddlewares
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def cors(config: CorsConfig = CorsConfig()): HttpAppMiddleware[Nothing, Any, Nothing, Any]
Creates a middleware for Cross-Origin Resource Sharing (CORS).
Creates a middleware for Cross-Origin Resource Sharing (CORS).
- Definition Classes
- Cors
- See also
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
- final def customAuth(verify: (Request) => Boolean, responseHeaders: Headers = Headers.empty, responseStatus: Status = Status.Unauthorized): 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.
- Definition Classes
- Auth
- final def customAuthProviding[R0, Context](provide: (Request) => Option[Context], responseHeaders: Headers = Headers.empty, responseStatus: Status = Status.Unauthorized)(implicit arg0: Tag[Context]): RequestHandlerMiddleware.WithOut[R0 with Context, Any, Nothing, Any, [Env]R0, [Err]Err]
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.
- Definition Classes
- Auth
- final def customAuthProvidingZIO[R0, R, E, Context](provide: (Request) => ZIO[R, E, Option[Context]], responseHeaders: Headers = Headers.empty, responseStatus: Status = Status.Unauthorized)(implicit arg0: Tag[Context]): RequestHandlerMiddleware.WithOut[R0 with R with Context, R, E, Any, [Env]R0 with R, [Err]Err]
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.
- Definition Classes
- Auth
- final def customAuthZIO[R, E](verify: (Request) => ZIO[R, E, Boolean], responseHeaders: Headers = Headers.empty, responseStatus: Status = Status.Unauthorized): 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.
- Definition Classes
- Auth
- 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
- Definition Classes
- RequestHandlerMiddlewares
- def dropTrailingSlash(onlyIfNoQueryParams: Boolean): HttpAppMiddleware[Nothing, Any, Nothing, Any]
Removes the trailing slash from the path.
Removes the trailing slash from the path.
- Definition Classes
- HttpRoutesMiddlewares
- def dropTrailingSlash: HttpAppMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HttpRoutesMiddlewares
- 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
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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.
- 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
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- 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]
- Definition Classes
- RequestHandlerMiddlewares
- final def ifRequestThenElseFunctionZIO[R, E](condition: (Request) => ZIO[R, E, Boolean])(ifTrue: (Request) => RequestHandlerMiddleware.Simple[R, E], ifFalse: (Request) => RequestHandlerMiddleware.Simple[R, E]): RequestHandlerMiddleware[Nothing, R, E, Any]
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- final def intercept(fromRequestAndResponse: (Request, Response) => Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- RequestHandlerMiddlewares
- final def interceptPatch[S](fromRequest: (Request) => S): InterceptPatch[S]
Creates a new middleware using transformation functions
Creates a new middleware using transformation functions
- Definition Classes
- RequestHandlerMiddlewares
- 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
- Definition Classes
- RequestHandlerMiddlewares
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def metrics(pathLabelMapper: PartialFunction[Request, String] = Map.empty, concurrentRequestsName: String = "http_concurrent_requests_total", totalRequestsName: String = "http_requests_total", requestDurationName: String = "http_request_duration_seconds", requestDurationBoundaries: Boundaries = Metrics.defaultBoundaries, extraLabels: Set[MetricLabel] = Set.empty): HttpAppMiddleware[Nothing, Any, Nothing, Any]
Adds metrics to a zio-http server.
Adds metrics to a zio-http server.
- pathLabelMapper
A mapping function to map incoming paths to patterns, such as /users/1 to /users/:id.
- totalRequestsName
Total HTTP requests metric name.
- requestDurationName
HTTP request duration metric name.
- requestDurationBoundaries
Boundaries for the HTTP request duration metric.
- extraLabels
A set of extra labels all metrics will be tagged with.
- Definition Classes
- Metrics
- Note
When using Prometheus as your metrics backend, make sure to provide a
pathLabelMapper
in order to avoid high cardinality labels.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- final def removeHeader(name: String): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- final def removeHeader(headerType: HeaderType): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- final def removeHeaders(headers: Set[String]): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- final def replace[R, E](newHandler: RequestHandler[R, E]): RequestHandlerMiddleware[Nothing, R, E, Any]
- Definition Classes
- RequestHandlerMiddlewares
- def replaceErrorResponse(request: Request, response: Response): Response
- Attributes
- protected
- Definition Classes
- HtmlErrorResponses
- final def requestLogging(level: (Status) => LogLevel = (_: Status) => LogLevel.Info, failureLevel: LogLevel = LogLevel.Warning, loggedRequestHeaders: Set[HeaderType] = Set.empty, loggedResponseHeaders: Set[HeaderType] = Set.empty, logRequestBody: Boolean = false, logResponseBody: Boolean = false, requestCharset: Charset = StandardCharsets.UTF_8, responseCharset: Charset = StandardCharsets.UTF_8)(implicit trace: Trace): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- RequestLogging
- 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
- Definition Classes
- RequestHandlerMiddlewares
- 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.
- Definition Classes
- RequestHandlerMiddlewares
- final def setHeaders(headers: Headers): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- HeaderModifier
- final def signCookies(secret: String): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
Creates a middleware for signing cookies
Creates a middleware for signing cookies
- Definition Classes
- RequestHandlerMiddlewares
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def timeout(duration: zio.Duration): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
Times out the application with a 408 status code.
Times out the application with a 408 status code.
- Definition Classes
- RequestHandlerMiddlewares
- def toString(): String
- Definition Classes
- AnyRef → Any
- final 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
- Definition Classes
- RequestHandlerMiddlewares → HeaderModifier
- 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
- Definition Classes
- RequestHandlerMiddlewares
- final def updateResponseZIO[R](f: (Response) => ZIO[R, Nothing, Response]): RequestHandlerMiddleware[Nothing, R, Nothing, Any]
- Definition Classes
- RequestHandlerMiddlewares
- 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]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- 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
- Definition Classes
- RequestHandlerMiddlewares
- 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
- Definition Classes
- RequestHandlerMiddlewares
- final def whenRequestZIO[R, E](condition: (Request) => ZIO[R, E, Boolean])(middleware: RequestHandlerMiddleware[Nothing, R, E, Any]): RequestHandlerMiddleware[Nothing, R, E, Any]
- Definition Classes
- RequestHandlerMiddlewares
- 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
- Definition Classes
- RequestHandlerMiddlewares
- 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
- Definition Classes
- RequestHandlerMiddlewares
- 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
- Definition Classes
- RequestHandlerMiddlewares
- def withHeader(header: Header): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
- Definition Classes
- 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
- Definition Classes
- RequestHandlerMiddlewares