gleam/http/response
Types
Functions
pub fn expire_cookie(
response: Response(a),
name: String,
attributes: Attributes,
) -> Response(a)
Expire a cookie value for a client
Note: The attributes value should be the same as when the response cookie was set.
pub fn get_cookies(resp: Response(a)) -> List(#(String, String))
Fetch the cookies sent in a response.
Badly formed cookies will be discarded.
pub fn get_header(
response: Response(a),
key: String,
) -> Result(String, Nil)
Get the value for a given header.
If the response does not have that header then Error(Nil)
is returned.
pub fn map(
response: Response(a),
transform: fn(a) -> b,
) -> Response(b)
Update the body of a response using a given function.
pub fn new(status: Int) -> Response(String)
Construct an empty Response.
The body type of the returned response is String
and could be set with a
call to set_body
.
pub fn prepend_header(
response: Response(a),
key: String,
value: String,
) -> Response(a)
Prepend the header with the given value under the given header key.
Similar to set_header
except if the header already exists it prepends
another header with the same key.
pub fn redirect(uri: String) -> Response(String)
Create a response that redirects to the given uri.
pub fn set_body(response: Response(a), body: b) -> Response(b)
Set the body of the response, overwriting any existing body.
pub fn set_cookie(
response: Response(a),
name: String,
value: String,
attributes: Attributes,
) -> Response(a)
Set a cookie value for a client
pub fn set_header(
response: Response(a),
key: String,
value: String,
) -> Response(a)
Set the header with the given value under the given header key.
If the response already has that key, it is replaced.