o

zio.http

HttpAppMiddleware

object HttpAppMiddleware extends RequestHandlerMiddlewares with HttpRoutesMiddlewares

Linear Supertypes
HttpRoutesMiddlewares, Cors, RequestHandlerMiddlewares, HtmlErrorResponses, HeaderModifier[RequestHandlerMiddleware[Nothing, Any, Nothing, Any]], Auth, Metrics, RequestLogging, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. HttpAppMiddleware
  2. HttpRoutesMiddlewares
  3. Cors
  4. RequestHandlerMiddlewares
  5. HtmlErrorResponses
  6. HeaderModifier
  7. Auth
  8. Metrics
  9. RequestLogging
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final class Allow extends AnyVal
  2. final class AllowZIO extends AnyVal
  3. trait Contextual[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr] extends AnyRef
  4. implicit final class HttpAppMiddlewareSyntax[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr] extends AnyVal
  5. trait Simple[-UpperEnv, +LowerErr] extends Contextual[Nothing, UpperEnv, LowerErr, Any]
  6. type WithOut[+LowerEnv, -UpperEnv, +LowerErr, -UpperErr, OutEnv0[_], OutErr0[_]] = Contextual[LowerEnv, UpperEnv, LowerErr, UpperErr] { ... /* 2 definitions in type refinement */ }

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def addCookie(cookie: Cookie.Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

    Sets cookie in response headers

    Sets cookie in response headers

    Definition Classes
    RequestHandlerMiddlewares
  5. final def addCookieZIO[R](cookie: ZIO[R, Nothing, Cookie.Response])(implicit trace: Trace): RequestHandlerMiddleware[Nothing, R, Nothing, Any]
    Definition Classes
    RequestHandlerMiddlewares
  6. final def addHeader(name: CharSequence, value: CharSequence): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  7. final def addHeader(header: Header): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  8. final def addHeaders(headers: Headers): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  9. def allow: Allow

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

  10. def allowZIO: AllowZIO

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

  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. final def beautifyErrors: RequestHandlerMiddleware[Nothing, Any, Nothing, Any]

    Beautify the error response.

    Beautify the error response.

    Definition Classes
    RequestHandlerMiddlewares
  18. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  19. 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

  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. def dropTrailingSlash: HttpAppMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HttpRoutesMiddlewares
  27. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  29. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  30. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  31. 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.

  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. final def intercept(fromRequestAndResponse: (Request, Response) => Response): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    RequestHandlerMiddlewares
  39. 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
  40. 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
  41. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  42. 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.

  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  45. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  46. 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
  47. 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
  48. 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
  49. 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
  50. final def removeHeader(name: String): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  51. final def removeHeader(headerType: HeaderType): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  52. final def removeHeaders(headers: Set[String]): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  53. final def replace[R, E](newHandler: RequestHandler[R, E]): RequestHandlerMiddleware[Nothing, R, E, Any]
    Definition Classes
    RequestHandlerMiddlewares
  54. def replaceErrorResponse(request: Request, response: Response): Response
    Attributes
    protected
    Definition Classes
    HtmlErrorResponses
  55. 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
  56. 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
  57. 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
  58. final def setHeaders(headers: Headers): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  59. 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
  60. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  61. 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
  62. def toString(): String
    Definition Classes
    AnyRef → Any
  63. 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
  64. 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
  65. final def updateResponseZIO[R](f: (Response) => ZIO[R, Nothing, Response]): RequestHandlerMiddleware[Nothing, R, Nothing, Any]
    Definition Classes
    RequestHandlerMiddlewares
  66. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  67. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  68. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  69. 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
  70. 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
  71. 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
  72. 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
  73. 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
  74. 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
  75. def withHeader(header: Header): RequestHandlerMiddleware[Nothing, Any, Nothing, Any]
    Definition Classes
    HeaderModifier
  76. 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

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from HttpRoutesMiddlewares

Inherited from Cors

Inherited from RequestHandlerMiddlewares

Inherited from HtmlErrorResponses

Inherited from Auth

Inherited from Metrics

Inherited from RequestLogging

Inherited from AnyRef

Inherited from Any

Ungrouped