zhttp.http

package zhttp.http

Type members

Classlikes

final case class Cookie(name: String, content: String, expires: Option[Instant], domain: Option[String], path: Option[Path], isSecure: Boolean, isHttpOnly: Boolean, maxAge: Option[Long], sameSite: Option[SameSite], secret: Option[String])
Companion:
object
object Cookie
Companion:
class
object HExit
object HeaderNames extends HeaderNames
object HeaderValues extends HeaderValues
final case class Headers(toChunk: Chunk[Header])

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
Companion:
class
sealed trait Http[-R, +E, -A, +B] extends A => ZIO[R, Option[E], B]

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
object Http
Companion:
class
sealed trait HttpData

Holds HttpData that needs to be written on the HttpChannel

Holds HttpData that needs to be written on the HttpChannel

Companion:
object
object HttpData
Companion:
class
sealed abstract class HttpError(val status: Status, val message: String) extends Throwable
Companion:
object
object HttpError
Companion:
class
@implicitNotFound("This operation is only valid if the incoming and outgoing type of Http are same.")
sealed trait IsMono[-AIn, +BIn, +AOut, -BOut]

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
object IsMono extends IsMono[Any, Nothing, Nothing, Any]
Companion:
class
final case class MediaType(mainType: String, subType: String, compressible: Boolean, binary: Boolean, fileExtensions: List[String], extensions: Map[String, String])
Companion:
object
object MediaType
Companion:
class
sealed trait Method
Companion:
object
object Method
Companion:
class
trait Middleware[-R, +E, +AIn, -BIn, -AOut, +BOut]

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
object Middleware
Companion:
class
sealed trait Patch

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
object Patch
Companion:
class
final case class Path(segments: Vector[String], trailingSlash: Boolean)
Companion:
object
object Path
Companion:
class
implicit class QueueWrapper[A](queue: Queue[A])
trait Request
Companion:
object
object Request
Companion:
class
final case class Response
Companion:
object
object Response
Companion:
class

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.

sealed trait Scheme
Companion:
object
object Scheme
Companion:
class
sealed trait Status extends Product with Serializable
Companion:
object
object Status
Companion:
class
final case class URL(path: Path, kind: Location, queryParams: Map[String, List[String]], fragment: Option[Fragment])
Companion:
object
object URL
Companion:
class
sealed trait Version
Companion:
object
object Version
Companion:
class

Inherited classlikes

object ->
Inherited from:
RequestSyntax
object /
Inherited from:
PathSyntax
object /:
Inherited from:
PathSyntax
abstract class RouteDecode[A](f: String => A)
Inherited from:
RouteDecoderModule
object boolean extends RouteDecode[Boolean]
Inherited from:
RouteDecoderModule
object byte extends RouteDecode[Byte]
Inherited from:
RouteDecoderModule
object date extends RouteDecode[LocalDate]
Inherited from:
RouteDecoderModule
object double extends RouteDecode[Double]
Inherited from:
RouteDecoderModule
object float extends RouteDecode[Float]
Inherited from:
RouteDecoderModule
object int extends RouteDecode[Int]
Inherited from:
RouteDecoderModule
object long extends RouteDecode[Long]
Inherited from:
RouteDecoderModule
object short extends RouteDecode[Short]
Inherited from:
RouteDecoderModule
object time extends RouteDecode[LocalDateTime]
Inherited from:
RouteDecoderModule
object uuid extends RouteDecode[UUID]
Inherited from:
RouteDecoderModule

Types

type Header = (CharSequence, CharSequence)
type HttpApp[-R, +E] = Http[R, E, Request, Response]
type RHttpApp[-R] = HttpApp[R, Throwable]
type ResponseZIO[-R, +E] = ZIO[R, E, Response]
type UHttp[-A, +B] = Http[Any, Nothing, A, B]
type UHttpApp = HttpApp[Any, Nothing]
type UMiddleware[+AIn, -BIn, -AOut, +BOut] = Middleware[Any, Nothing, AIn, BIn, AOut, BOut]

Value members

Concrete fields

val HTTP_CHARSET: Charset

Default HTTP Charset

Default HTTP Charset

Inherited fields

val !!: Path
Inherited from:
PathSyntax

Implicits

Implicits

final implicit def QueueWrapper[A](queue: Queue[A]): QueueWrapper[A]