Middleware

object Middleware extends Web
Companion:
class
trait Web
trait HeaderModifier[HttpMiddleware[Any, Nothing]]
trait Auth
trait Csrf
trait Cors
class Object
trait Matchable
class Any

Type members

Classlikes

final class PartialCodec[AOut, BIn](val unit: Unit) extends AnyVal
final class PartialCodecHttp[AOut, BIn](val unit: Unit) extends AnyVal
final class PartialCodecZIO[AOut, BIn](val unit: Unit) extends AnyVal
final class PartialCollect[AOut](val unit: Unit) extends AnyVal
final class PartialCollectZIO[AOut](val unit: Unit) extends AnyVal
final class PartialContraMapZIO[-R, +E, +AIn, -BIn, -AOut, +BOut, AOut0](val self: Middleware[R, E, AIn, BIn, AOut, BOut]) extends AnyVal
final class PartialIfThenElse[AOut](val unit: Unit) extends AnyVal
final class PartialIfThenElseZIO[AOut](val unit: Unit) extends AnyVal
final class PartialIntercept[A, B](val unit: Unit) extends AnyVal
final class PartialInterceptOutgoingZIO[-R, +E, A, +S, B](val incoming: A => ZIO[R, Option[E], S]) extends AnyVal
final class PartialInterceptZIO[A, B](val unit: Unit) extends AnyVal

Value members

Concrete methods

def codec[A, B]: PartialCodec[A, B]

Creates a middleware using the specified encoder and decoder functions

Creates a middleware using the specified encoder and decoder functions

def codecHttp[A, B]: PartialCodecHttp[A, B]

Creates a codec middleware using two Http.

Creates a codec middleware using two Http.

def codecZIO[A, B]: PartialCodecZIO[A, B]

Creates a middleware using specified effectful encoder and decoder

Creates a middleware using specified effectful encoder and decoder

Creates a middleware using specified function

Creates a middleware using specified function

Creates a middleware using specified effect function

Creates a middleware using specified effect function

def fail[E](e: E): Middleware[Any, E, Nothing, Any, Any, Nothing]

Creates a middleware which always fail with specified error

Creates a middleware which always fail with specified error

def fromHttp[R, E, A, B](http: Http[R, E, A, B]): Middleware[R, E, Nothing, Any, A, B]

Creates a middleware with specified http App

Creates a middleware with specified http App

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

An empty middleware that doesn't do anything

An empty middleware that doesn't do anything

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

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

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

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

def intercept[A, B]: PartialIntercept[A, B]

Creates a new middleware using transformation functions

Creates a new middleware using transformation functions

Creates a new middleware using effectful transformation functions

Creates a new middleware using effectful transformation functions

def succeed[B](b: B): Middleware[Any, Nothing, Nothing, Any, Any, B]

Creates a middleware which always succeed with specified value

Creates a middleware which always succeed with specified value

Inherited methods

final def addCookie(cookie: Cookie): HttpMiddleware[Any, Nothing]

Sets cookie in response headers

Sets cookie in response headers

Inherited from:
Web
final def addCookieZIO[R, E](cookie: ZIO[R, E, Cookie]): HttpMiddleware[R, E]
Inherited from:
Web
final def addHeader(name: CharSequence, value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def addHeader(header: Header): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def addHeaders(headers: Headers): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def basicAuth(u: String, p: String): HttpMiddleware[Any, Nothing]

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

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

Creates a middleware for basic authentication

Creates a middleware for basic authentication

Inherited from:
Auth
final def basicAuthZIO[R, E](f: Credentials => ZIO[R, E, Boolean]): HttpMiddleware[R, E]

Creates a middleware for basic authentication using an effectful verification function

Creates a middleware for basic authentication using an effectful verification function

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

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

Value parameters:
f:

function that validates the token string inside the Bearer Header

Inherited from:
Auth
final def bearerAuthZIO[R, E](f: String => ZIO[R, E, Boolean]): HttpMiddleware[R, E]

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

Value parameters:
f:

function that effectfully validates the token string inside the Bearer Header

Inherited from:
Auth
final def cors[R, E](config: CorsConfig): HttpMiddleware[R, E]

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

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

See also:
Inherited from:
Cors
final def csrfGenerate[R, E](tokenName: String, tokenGen: ZIO[R, Nothing, String]): HttpMiddleware[R, E]

Generates a new CSRF token that can be validated using the csrfValidate middleware.

Generates a new CSRF token that can be validated using the csrfValidate middleware.

CSRF middlewares: To prevent Cross-site request forgery attacks. This middleware is modeled after the double submit cookie pattern. Used in conjunction with csrfValidate middleware.

https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie

Inherited from:
Csrf
def csrfValidate(tokenName: String): HttpMiddleware[Any, Nothing]

Validates the CSRF token appearing in the request headers. Typically the token should be set using the csrfGenerate middleware.

Validates the CSRF token appearing in the request headers. Typically the token should be set using the csrfGenerate middleware.

CSRF middlewares : To prevent Cross-site request forgery attacks. This middleware is modeled after the double submit cookie pattern. Used in conjunction with csrfGenerate middleware

https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie

Inherited from:
Csrf
final def customAuth(verify: Headers => Boolean, responseHeaders: Headers, responseStatus: Status): HttpMiddleware[Any, Nothing]

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.

Inherited from:
Auth
final def customAuthZIO[R, E](verify: Headers => ZIO[R, E, Boolean], responseHeaders: Headers, responseStatus: Status): HttpMiddleware[R, E]

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.

Inherited from:
Auth
final def debug: HttpMiddleware[Console & Clock, IOException]

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

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

Inherited from:
Web
final def ifHeaderThenElse[R, E](cond: Headers => Boolean)(left: HttpMiddleware[R, E], right: HttpMiddleware[R, E]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def ifMethodThenElse[R, E](cond: Method => Boolean)(left: HttpMiddleware[R, E], right: HttpMiddleware[R, E]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def ifRequestThenElse[R, E](cond: Request => Boolean)(left: HttpMiddleware[R, E], right: HttpMiddleware[R, E]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def ifRequestThenElseZIO[R, E](cond: Request => ZIO[R, E, Boolean])(left: HttpMiddleware[R, E], right: HttpMiddleware[R, E]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def interceptPatch[S](req: Request => S): PartialInterceptPatch[S]

Creates a new middleware using transformation functions

Creates a new middleware using transformation functions

Inherited from:
Web
final def interceptZIOPatch[R, E, S](req: Request => ZIO[R, Option[E], S]): PartialInterceptZIOPatch[R, E, S]

Creates a new middleware using effectful transformation functions

Creates a new middleware using effectful transformation functions

Inherited from:
Web
final def patch[R, E](f: Response => Patch): HttpMiddleware[R, E]

Creates a middleware that produces a Patch for the Response

Creates a middleware that produces a Patch for the Response

Inherited from:
Web
final def patchZIO[R, E](f: Response => ZIO[R, Option[E], Patch]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def removeHeader(name: String): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def removeHeaders(headers: List[String]): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def runAfter[R, E](effect: ZIO[R, E, Any]): HttpMiddleware[R, E]

Runs the effect after the middleware is applied

Runs the effect after the middleware is applied

Inherited from:
Web
final def runBefore[R, E](effect: ZIO[R, E, Any]): HttpMiddleware[R, E]

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.

Inherited from:
Web
final def setHeaders(headers: Headers): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def setStatus(status: Status): HttpMiddleware[Any, Nothing]

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

Inherited from:
Web
final def signCookies(secret: String): HttpMiddleware[Any, Nothing]

Creates a middleware for signing cookies

Creates a middleware for signing cookies

Inherited from:
Web
final def timeout(duration: Duration): HttpMiddleware[Clock, Nothing]

Times out the application with a 408 status code.

Times out the application with a 408 status code.

Inherited from:
Web
final override def updateHeaders(update: Headers => Headers): HttpMiddleware[Any, Nothing]

Updates the provided list of headers to the response

Updates the provided list of headers to the response

Definition Classes
Inherited from:
Web
final def updateResponse[R, E](f: Response => Response): HttpMiddleware[R, E]

Creates a middleware that updates the response produced

Creates a middleware that updates the response produced

Inherited from:
Web
final def whenHeader[R, E](cond: Headers => Boolean, middleware: HttpMiddleware[R, E]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def whenRequest[R, E](cond: Request => Boolean)(middleware: HttpMiddleware[R, E]): HttpMiddleware[R, E]

Applies the middleware only if the condition function evaluates to true

Applies the middleware only if the condition function evaluates to true

Inherited from:
Web
final def whenRequestZIO[R, E](cond: Request => ZIO[R, E, Boolean])(middleware: HttpMiddleware[R, E]): HttpMiddleware[R, E]

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

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

Inherited from:
Web
final def withAccept(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAcceptCharset(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAcceptEncoding(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAcceptLanguage(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAcceptPatch(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAcceptRanges(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
Inherited from:
HeaderModifier
final def withAccessControlAllowHeaders(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAccessControlAllowMethods(value: Method*): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAccessControlAllowOrigin(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAccessControlExposeHeaders(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAccessControlMaxAge(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAccessControlRequestHeaders(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAccessControlRequestMethod(value: Method): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAge(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAllow(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withAuthorization(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withBasicAuthorization(username: String, password: String): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withCacheControl(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withCacheControlMaxAge(value: Duration): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withConnection(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentBase(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentDisposition(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentEncoding(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentLanguage(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentLength(value: Long): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentLocation(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentMd5(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentRange(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentSecurityPolicy(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentTransferEncoding(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withContentType(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withCookie(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withDate(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withDnt(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withEtag(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withExpect(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withExpires(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withFrom(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withHost(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withIfMatch(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withIfModifiedSince(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withIfNoneMatch(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withIfRange(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withIfUnmodifiedSince(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withLastModified(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withLocation(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withMaxForwards(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
def withMediaType(mediaType: MediaType): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withOrigin(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withPragma(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withProxyAuthenticate(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withProxyAuthorization(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withRange(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withReferer(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withRetryAfter(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketAccept(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketExtensions(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketKey(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketLocation(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketOrigin(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketProtocol(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSecWebSocketVersion(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withServer(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withSetCookie(value: Cookie): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withTe(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withTrailer(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withTransferEncoding(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withUpgrade(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withUpgradeInsecureRequests(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withUserAgent(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withVary(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withVia(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withWarning(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withWebSocketLocation(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withWebSocketOrigin(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withWebSocketProtocol(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withWwwAuthenticate(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withXFrameOptions(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier
final def withXRequestedWith(value: CharSequence): HttpMiddleware[Any, Nothing]
Inherited from:
HeaderModifier