pub struct LinoRequest {
pub method: String,
pub path: String,
pub headers: Headers,
pub params: PathParams,
pub query_string: String,
pub body: Option<LinoValue>,
pub media_type: String,
pub request_media_type: Option<String>,
pub query_defaults: QueryDefaults,
}Expand description
One HTTP request, decoded according to the specification.
Fields§
§method: StringHTTP method, upper-cased.
path: StringRequest path, without the query string.
headers: HeadersRequest headers, looked up without regard to case.
params: PathParamsPath parameters captured by the matched route.
query_string: StringRaw query string, without its leading ?.
body: Option<LinoValue>Decoded request body, or None when the request carried none.
media_type: StringThe representation the response will be encoded as.
request_media_type: Option<String>The media type the request body arrived in.
query_defaults: QueryDefaultsPage-size defaults inherited from the application.
Implementations§
Source§impl LinoRequest
impl LinoRequest
Sourcepub fn new<M: Into<String>, P: Into<String>>(method: M, path: P) -> Self
pub fn new<M: Into<String>, P: Into<String>>(method: M, path: P) -> Self
A request with a method and a path, and nothing else set.
Sourcepub fn param(&self, name: &str) -> Option<String>
pub fn param(&self, name: &str) -> Option<String>
Read a path parameter, percent-decoded.
§Examples
use lino_rest_api::request::LinoRequest;
let mut request = LinoRequest::new("GET", "/tasks/a%20b");
request.params.insert("id".to_string(), "a%20b".to_string());
assert_eq!(request.param("id").as_deref(), Some("a b"));Sourcepub fn query(&self) -> QueryParams
pub fn query(&self) -> QueryParams
Query parameters, with repeated parameters kept in order.
Sourcepub fn collection_query(&self) -> Result<CollectionQuery, LinoHttpError>
pub fn collection_query(&self) -> Result<CollectionQuery, LinoHttpError>
Parse the query string as a collection query (specification section 6).
§Errors
A 400 when limit or offset is not a non-negative integer.
Sourcepub fn require_body(&self) -> Result<&LinoValue, LinoHttpError>
pub fn require_body(&self) -> Result<&LinoValue, LinoHttpError>
The request body, or a 400 when the request carried none.
§Errors
A 400 when the body is absent, which is what a POST without one is.
Trait Implementations§
Source§impl Clone for LinoRequest
impl Clone for LinoRequest
Source§fn clone(&self) -> LinoRequest
fn clone(&self) -> LinoRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more