Module Morph__.Response
type body
=[
|
`String(string)
Use a simple string as body
|
`Stream(Lwt_stream.t(char))
Use a stream of chars as body
|
`StringStream(Lwt_stream.t(string))
Use a stream of strings as body
]
;Response.body
variant type structure. There are currently 3 types of bodies.`String
Use a simple string as body`Stream
Use a stream of chars as body, the stream will be written fully before flushing`StringStream
Use a stream of strings as body, it will be flushed on every new string
type t
=
{
status: Morph.Status.t,
headers: headers,
body: body,
}
;The core
Response.t
type
let make: ?status:Morph.Status.t => ?headers:headers => body => t;
make status headers body
creates a response.
let empty: t;
empty t
an empty response, a starting place to compose an http response.
let add_header: (string, string) => t => t;
add_header header response
returns a copy of t of response with the header tuple added.
let add_headers: headers => t => t;
add_header headers response
returns a copy of t of response with the headers added.
let set_status: Morph.Status.t => t => t;
set_status status response
returns a copy of t with the given status.
let text: string => t => Lwt.t(t);
text text response
is a conventience function to return a text response.
let json: string => t => Lwt.t(t);
json json response
is a conventience function to return a JSON response.
let html: string => t => Lwt.t(t);
html markup response
is a conventience function to return a HTML response.
let redirect: ?code:int => string => t => Lwt.t(t);
redirect code target response
is a conventience function to create a redirect response.
let unauthorized: string => t => Lwt.t(t);
unauthorized message response
is a conventience function to return a unauthorized response.