radiant/request
Request accessors, context keys, and request errors.
Types
Errors returned by request and context accessors.
pub type RadiantError {
MissingHeader(String)
InvalidUtf8Body
MissingPathParam(String)
InvalidIntParam(String, String)
MissingQuery(String)
InvalidIntQuery(String, String)
InvalidFloatQuery(String, String)
InvalidBoolQuery(String, String)
MalformedQuery(String)
MissingContext(String)
}
Constructors
-
MissingHeader(String) -
InvalidUtf8Body -
MissingPathParam(String) -
InvalidIntParam(String, String) -
MissingQuery(String) -
InvalidIntQuery(String, String) -
InvalidFloatQuery(String, String) -
InvalidBoolQuery(String, String) -
MalformedQuery(String) -
MissingContext(String)
Values
pub fn from_request(request: request.Request(BitArray)) -> Req
Low-level helper used by radiant/router to wrap an HTTP request.
pub fn get_context(
req: Req,
k: Key(a),
) -> Result(a, RadiantError)
Retrieve a typed value from the request context.
pub fn header(
req: Req,
key: String,
) -> Result(String, RadiantError)
Get a request header by key.
pub fn int_param(
req: Req,
name: String,
) -> Result(Int, RadiantError)
Extract a path parameter as Int.
pub fn key_named(namespace: String, name: String) -> Key(a)
Create a typed context key with an explicit namespace.
pub fn original(req: Req) -> request.Request(BitArray)
Access the underlying Request(BitArray).
pub fn query(
req: Req,
key: String,
) -> Result(String, RadiantError)
Get a single query parameter by key.
pub fn query_bool(
req: Req,
key: String,
) -> Result(Bool, RadiantError)
Get a query parameter parsed as Bool.
pub fn query_float(
req: Req,
key: String,
) -> Result(Float, RadiantError)
Get a query parameter parsed as Float.
pub fn query_int(
req: Req,
key: String,
) -> Result(Int, RadiantError)
Get a query parameter parsed as Int.
pub fn set_context(req: Req, k: Key(a), value: a) -> Req
Store a typed value in the request context.
pub fn str_param(
req: Req,
name: String,
) -> Result(String, RadiantError)
Extract a path parameter as String.
pub fn text_body(req: Req) -> Result(String, RadiantError)
The request body decoded as UTF-8 text.
pub fn with_method(req: Req, method: http.Method) -> Req
Low-level helper used by radiant/router for HEAD-to-GET dispatch.