Copyright © 2016-2019 Marc Worrell
Authors: Marc Worrell (marc@worrell.nl).
context() = context_map() | tuple()
context_map() = #{cowreq := cowboy_req:req(), cowenv := cowboy_middleware:env(), any() => any()}
halt() = {error, term()} | {halt, 200..599}
media_type() = binary() | {binary(), binary(), [{binary(), binary()}]} | {binary(), binary()} | {binary(), [{binary(), binary()}]}
outputfun() = fun((iodata(), IsFinal::boolean(), context()) -> context())
parts() = all | {ranges(), Size::non_neg_integer(), Boundary::binary(), ContentType::binary()}
ranges() = [{Offset::non_neg_integer(), Length::non_neg_integer()}]
resp_body() = iodata() | {device, Size::non_neg_integer(), file:io_device()} | {device, file:io_device()} | {file, Size::non_neg_integer(), file:filename_all()} | {file, file:filename_all()} | {stream, {streamdata(), streamfun()}} | {stream, Size::non_neg_integer(), {streamdata(), streamfun()}} | {stream, streamfun()} | {stream, Size::non_neg_integer(), streamfun()} | {writer, writerfun()} | undefined
streamdata() = iodata() | {file, non_neg_integer(), file:filename_all()} | {file, file:filename_all()}
streamfun() = fun((parts(), context()) -> {streamdata(), streamfun_next()}) | fun((context()) -> {streamdata(), streamfun_next()}) | fun(() -> {streamdata(), streamfun_next()}) | done
streamfun_next() = fun((context()) -> {streamdata(), streamfun_next()}) | fun(() -> {streamdata(), streamfun_next()}) | done
writerfun() = fun((outputfun(), context()) -> context())
base_uri/1 | Return the base uri of the request. |
controller/1 | Return the current cowmachine controller. |
controller_options/1 | Return the current cowmachine controller options. |
disp_path/1 | Return the dispatch path of the request. |
encode_content/2 | Encode the content according to the selected content encoding. |
env/1 | Fetch the cowboy middleware env from the context. |
get_cookie_value/2 | Fetch the value of a cookie. |
get_metadata/2 | |
get_req_header/2 | Fetch a request header, the header must be a lowercase binary. |
get_req_headers/1 | Fetch all request headers. |
get_resp_cookies/1 | Fetch all response cookies. |
get_resp_header/2 | Fetch the response header, undefined if not set. |
get_resp_headers/1 | Fetch all response headers. |
has_req_body/1 | Check if the request has a body. |
has_resp_body/1 | Check if a response body has been set. |
host/1 | Return the http host. |
init_context/3 | Initialize the context with the Req and Env. |
init_env/2 | Set some intial metadata in the cowboy req. |
is_proxy/1 | Check if the request is forwarded by a proxy. |
is_range_ok/1 | Fetch the 'is_range_ok' flag. |
is_ssl/1 | Check if the connection is secure (SSL). |
method/1 | Return the request Method. |
path/1 | Return the undecoded request path as-is. |
path_info/1 | Fetch all bindings from the dispatcher. |
peer/1 | Return the peer of this request, take x-forwarded-for into account if the peer is an ip4 LAN address. |
peer_ip/1 | Return the peer of this request, take x-forwarded-for into account if the peer is an ip4 LAN address. |
port/1 | Return the http port. |
qs/1 | Return the undecoded query string, <<>> when no query string. |
raw_path/1 | Return the undecoded request path as-is, including the query string. |
remove_resp_header/2 | Remove the response header from the list for response headers. |
req/1 | Fetch the cowboy request from the context. |
req_body/1 | Fetch the request body as a single binary. |
req_body/2 | |
req_cookie/1 | Fetch all cookies. |
req_qs/1 | Return the decoded query string, [] when no query string. |
resp_body/1 | Return the response body, this must be converted to a response body that Cowboy can handle. |
resp_chosen_charset/1 | Get the chosen charset. |
resp_content_encoding/1 | Get the content encoding. |
resp_content_type/1 | Fetch the content type of the response. |
resp_redirect/1 | Return the 'redirect' flag, used during POST processing to check if a 303 should be returned. |
resp_transfer_encoding/1 | Get the transfer encoding. |
response_code/1 | Fetch the preliminary HTTP response code for the request. |
scheme/1 | Return the scheme used (https or http). |
set_disp_path/2 | Set the dispatch path of the request. |
set_env/2 | Update the cowboy middleware env in the context. |
set_metadata/3 | |
set_range_ok/2 | Set the 'is_range_ok' flag. |
set_req/2 | Update the cowboy request in the context. |
set_resp_body/2 | Set the response body, this must be converted to a response body that Cowboy can handle. |
set_resp_chosen_charset/2 | Set the chosen charset. |
set_resp_content_encoding/2 | Set the content encoding. |
set_resp_content_type/2 | Set the content type of the response. |
set_resp_cookie/4 | Add a cookie to the response cookies. |
set_resp_header/3 | Add a response header, replacing an existing header with the same name. |
set_resp_headers/2 | Set multiple response headers. |
set_resp_redirect/2 | Set the 'redirect' flag, used during POST processing to check if a 303 should be returned. |
set_resp_transfer_encoding/2 | Set the transfer encoding. |
set_response_code/2 | Set the preliminary HTTP response code for the request. |
site/1 | Return the cowmachine site. |
stream_req_body/2 | |
version/1 | Return the http version as a tuple {minor,major}. |
base_uri(Context::context()) -> binary()
Return the base uri of the request.
controller(Context::context()) -> module()
Return the current cowmachine controller
controller_options(Context::context()) -> list()
Return the current cowmachine controller options
disp_path(Context::context()) -> binary() | undefined
Return the dispatch path of the request.
encode_content(Content::iodata(), Context::context()) -> iolist()
Encode the content according to the selected content encoding
env(Context::context()) -> cowboy_middleware:env()
Fetch the cowboy middleware env from the context.
get_cookie_value(Name::binary(), Context::context()) -> binary() | undefined
Fetch the value of a cookie.
get_metadata(Key::atom(), Context::context()) -> term() | undefined
get_req_header(H::binary(), Context::context()) -> binary() | undefined
Fetch a request header, the header must be a lowercase binary.
get_req_headers(Context::context()) -> #{binary() => binary()}
Fetch all request headers.
get_resp_cookies(Context::context()) -> [{binary(), binary()}]
Fetch all response cookies.
get_resp_header(Header::binary(), Context::context()) -> binary() | undefined
Fetch the response header, undefined if not set.
get_resp_headers(Context::context()) -> map()
Fetch all response headers.
has_req_body(Context::context()) -> boolean()
Check if the request has a body
has_resp_body(Context::context()) -> boolean()
Check if a response body has been set.
host(Context::context()) -> binary()
Return the http host
init_context(Req::cowboy_req:req(), Env::cowboy_middleware:env(), M::undefined | map() | tuple()) -> context()
Initialize the context with the Req and Env
init_env(Req::cowboy_req:req(), Env::cowboy_middleware:env()) -> cowboy_middleware:env()
Set some intial metadata in the cowboy req
is_proxy(Context::context()) -> boolean()
Check if the request is forwarded by a proxy
is_range_ok(Context::context()) -> boolean()
Fetch the 'is_range_ok' flag.
is_ssl(Context::context()) -> boolean()
Check if the connection is secure (SSL)
method(Context::context()) -> binary()
Return the request Method
path(Context::context()) -> binary()
Return the undecoded request path as-is
path_info(Context::context()) -> cowboy_router:bindings()
Fetch all bindings from the dispatcher.
peer(Context::context()) -> binary()
Return the peer of this request, take x-forwarded-for into account if the peer is an ip4 LAN address
peer_ip(Context::context()) -> tuple()
Return the peer of this request, take x-forwarded-for into account if the peer is an ip4 LAN address
port(Context::context()) -> integer()
Return the http port
qs(Context::context()) -> binary()
Return the undecoded query string, <<>> when no query string.
raw_path(Context::context()) -> binary()
Return the undecoded request path as-is, including the query string
Remove the response header from the list for response headers.
req(Context::context()) -> cowboy_req:req()
Fetch the cowboy request from the context.
Fetch the request body as a single binary. Per default we don't receive more than ~128K bytes.
req_cookie(Context::context()) -> list()
Fetch all cookies.
req_qs(Context::context()) -> [{binary(), binary()}]
Return the decoded query string, [] when no query string.
resp_body(Context::context()) -> resp_body()
Return the response body, this must be converted to a response body that Cowboy can handle.
resp_chosen_charset(Context::context()) -> binary() | undefined
Get the chosen charset.
resp_content_encoding(Context::context()) -> binary()
Get the content encoding.
resp_content_type(Context::context()) -> cow_http_hd:media_type()
Fetch the content type of the response
resp_redirect(Context::context()) -> boolean()
Return the 'redirect' flag, used during POST processing to check if a 303 should be returned.
resp_transfer_encoding(Context::context()) -> {binary(), function()} | undefined
Get the transfer encoding.
response_code(Context::context()) -> integer()
Fetch the preliminary HTTP response code for the request. This can be changed.
scheme(Context::context()) -> http | https
Return the scheme used (https or http)
Set the dispatch path of the request.
set_env(Env::cowboy_middleware:env(), Context::context()) -> context()
Update the cowboy middleware env in the context.
Set the 'is_range_ok' flag.
set_req(Req::cowboy_req:req(), Context::context()) -> context()
Update the cowboy request in the context.
set_resp_body(RespBody::resp_body(), Context::context()) -> context()
Set the response body, this must be converted to a response body that Cowboy can handle.
Set the chosen charset.
Set the content encoding
set_resp_content_type(CT::cow_http_hd:media_type() | binary(), Context::context()) -> context()
Set the content type of the response
Add a cookie to the response cookies
set_resp_header(Header::binary(), Rs::binary() | [binary()] | string(), Context::context()) -> context()
Add a response header, replacing an existing header with the same name. The header must be a lowercased binary. If the value is a list of binaries then they are joined with a comma as separator.
Set multiple response headers.
Set the 'redirect' flag, used during POST processing to check if a 303 should be returned.
Set the transfer encoding
Set the preliminary HTTP response code for the request. This can be changed.
site(Context::context()) -> atom()
Return the cowmachine site.
stream_req_body(ChunkSize::non_neg_integer(), Context::context()) -> {ok | more, binary(), context()}
version(Context::context()) -> {Major::integer(), Minor::integer()}
Return the http version as a tuple {minor,major}.
Generated by EDoc