zhttp.http
Type members
Classlikes
Represents an immutable collection of headers i.e. essentially a Chunk[(String, String)]. It extends HeaderExtensions and has a ton of powerful operators that can be used to add, remove and modify headers.
Represents an immutable collection of headers i.e. essentially a Chunk[(String, String)]. It extends HeaderExtensions and has a ton of powerful operators that can be used to add, remove and modify headers.
NOTE: Generic operators that are not specific to Headers
should not be
defined here. A better place would be one of the traits extended by
HeaderExtension
.
- Companion:
- object
A functional domain to model Http apps using ZIO and that can work over any kind of request and response types.
A functional domain to model Http apps using ZIO and that can work over any kind of request and response types.
- Companion:
- object
Holds HttpData that needs to be written on the HttpChannel
Holds HttpData that needs to be written on the HttpChannel
- Companion:
- object
- Companion:
- object
IsMono is a type-constraint that is used by the middleware api for allowing some operators only when the following condition is met.
IsMono is a type-constraint that is used by the middleware api for allowing some operators only when the following condition is met.
Condition: Since a middleware takes in an Http and returns a new Http, IsMono, makes sure that the type parameters of the incoming Http and the ones for the outgoing Http is the same.
For Eg: IsMono will be defined for a middleware that looks as follows
val mid: Middleware[Any, Nothing, Request, Response, Request, Response]
This is because both the middleware is defined from (Request, Response) => (Request, Response). Consider another example:
val mid: Middleware[Any, Nothing, Request, Response, UserRequest, UserResponse]
In this case, the incoming and outgoing types are different viz. (Request, Response) => (UserRequest, UserResponse), hence there is no IsMono defined for such middlewares.
- Companion:
- object
Middlewares are essentially transformations that one can apply on any Http to produce a new one. They can modify requests and responses and also transform them into more concrete domain entities.
Middlewares are essentially transformations that one can apply on any Http to produce a new one. They can modify requests and responses and also transform them into more concrete domain entities.
You can think of middlewares as a functions —
type Middleware[R, E, AIn, BIn, AOut, BOut] = Http[R, E, AIn, BIn] => Http[R, E, AOut, BOut]
The AIn
and BIn
type params represent the type params of the input Http.
The AOut
and BOut
type params represent the type params of the output
Http.
- Companion:
- object
Models the set of operations that one would want to apply on a Response.
Models the set of operations that one would want to apply on a Response.
- Companion:
- object
Instead of using just String
as path params, using the RouteDecoderModule
we can extract and converted params into a specific type also.
Instead of using just String
as path params, using the RouteDecoderModule
we can extract and converted params into a specific type also.
Http.collect[Request] {
case GET -> !! / "user" / int(id) => Response.text("User id requested: ${id}")
case GET -> !! / "user" / name => Response.text("User name requested: ${name}")
}
If the request looks like GET /user/100
then it would match the first case.
This is because internally the id
param can be decoded into an Int
. If a
request of the form GET /user/zio
is made, in that case the second case is
matched.