package vif

  1. Overview
  2. Docs

Module Vif.RequestSource

Sourcetype ('c, 'a) t

Type of a request.

Sourceval target : ('c, 'a) t -> string

target req corresponds to the path requested by the request req. The invariant is that it always starts with a slash '/' .

Sourceval meth : ('c, 'a) t -> Method.t

meth req is the method (see Method) of the given request req.

Sourceval version : ('c, 'a) t -> int

version req is the HTTP version used to communicate.

Sourceval headers : ('c, 'a) t -> Headers.t

headers req returns headers (see Headers) of the given request req.

Sourceval accept : ('c, 'a) t -> string list

accept req returns what the client can accept and understand.

Sourceval of_json : (Type.json, 'a) t -> ('a, [> `Msg of string ]) result
Sourceval of_multipart_form : (Type.multipart_form, 'a) t -> ('a, [> `Not_found of string | `Invalid_multipart_form ]) result
Sourceval source : ('c, 'a) t -> string Flux.source
Sourceval get : ('cfg, 'v) Middleware.t -> ('c, 'a) t -> 'v option

get middleware req returns the value optionally added by the given middleware and the request req.

Requests for middlewares

As soon as it comes to executing the various middlewares (Middleware.t) defined by the user, the latter can manipulate the HTTP request given by the client. However, the latter has a limitation: the body of the request cannot be obtained from the request type of value. Indeed, middlewares should not manipulate the body of requests and should only refer to meta-data (such as headers).

Sourcetype request

Type of a request (in the view of a middleware).

Sourceval headers_of_request : request -> Headers.t

headers_of_request is the headers (see Headers) of the given request.

Sourceval method_of_request : request -> Method.t

method_of_request is the method (see Method) of the given request.

Sourceval target_of_request : request -> string

target_of_request is the path of the given request.