Request

io.eezo.http.Request
See theRequest companion object
final case class Request(method: Method, path: String, query: Map[String, Seq[String]], headers: Map[String, Seq[String]], body: Array[Byte], pathParams: Map[String, String], session: Session = ..., secure: Boolean = ..., currentUser: Option[String] = ...)

One request, read whole.

The body is eager and capped: HttpApp.maxBodySize decides how much of it is read, and exceeding the cap is a 413 rather than a stream nobody drains. What is deliberately absent is an untyped attachment: AnyRef bag. A capability arrives through the handler's using list, where its absence is a compile error rather than a sys.error on the first request that needs it.

The session is read for the handler out of the signed cookie once the route has matched, and only on a browser route: no session takes part in an API route, so a request there carries the empty one whatever cookie it sent, and so does a request built by hand until a test says otherwise with copy.

secure is whether the browser reached the application over HTTPS, which is what decides a cookie's Secure attribute. A request built by hand is not.

currentUser is who the guard says is behind this request, as the key the session spells it with, and it is a fact about the request rather than a way to ask one: http holds the value and whoever owns the rule, a guard, holds the rule. It is written before the handler it is for runs, by the guard's own wrapper on a guarded page and by the route table's identify on a socket upgrade, and never from a header, a query or path parameter, or a frame, all of which a client chooses. Nobody is None, which is what every request in an application with no way of signing in carries, and what a request built by hand carries until something names it.

Attributes

Companion
object
Source
Request.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def as[A](using f: Form[A]): Either[FormErrors, A]
Extension method from io.eezo.http

For a model with no key field.

For a model with no key field.

Attributes

Source
Form.scala
def csrf: Token

The CSRF token this browser's forms must carry: what a handler hands to Form.render and Csrf.hidden. Dispatch mints one into the session before any handler on a browser route runs, so inside one this cannot fail; a request built by hand and never dispatched has none, and asking is a bug in the caller rather than a bad request.

The CSRF token this browser's forms must carry: what a handler hands to Form.render and Csrf.hidden. Dispatch mints one into the session before any handler on a browser route runs, so inside one this cannot fail; a request built by hand and never dispatched has none, and asking is a bug in the caller rather than a bad request.

Attributes

Throws
IllegalStateException

on a request dispatch has never seen, which has no token to hand out.

Source
Request.scala
def header(name: String): Option[String]

A header, case insensitively, first value wins.

A header, case insensitively, first value wins.

Attributes

Source
Request.scala
def param[A](name: String)(using from: FromPath[A]): A

A path parameter, converted. Throws BadRequest, which the boundary maps to a 400.

A path parameter, converted. Throws BadRequest, which the boundary maps to a 400.

Attributes

Source
Request.scala
def paramOpt[A](name: String)(using from: FromPath[A]): Option[A]

The non throwing form of param.

The non throwing form of param.

Attributes

Source
Request.scala
def queryParam(name: String): Option[String]

A query parameter, first value wins.

A query parameter, first value wins.

Attributes

Source
Request.scala

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala

Concrete fields

lazy val cookies: Map[String, String]

The Cookie header, split into pairs, decoded once and remembered. Every header of that name counts, and the first of a repeated name wins. What a handler reads for its own cookies; on a browser route the session cookie is read for it, into session, once the route has matched.

The Cookie header, split into pairs, decoded once and remembered. Every header of that name counts, and the first of a repeated name wins. What a handler reads for its own cookies; on a browser route the session cookie is read for it, into session, once the route has matched.

Attributes

Source
Request.scala
lazy val form: Map[String, Seq[String]]

The form encoded body, decoded once and remembered.

The form encoded body, decoded once and remembered.

Multi valued, because checkbox groups and multi selects genuinely produce repeats and a Map[String, String] drops them in silence. Memoised, because the _method override reads the body before dispatch and the handler reads it again. multipart/form-data is out of scope: this is application/x-www-form-urlencoded only.

Attributes

Source
Request.scala