pub struct Query<Q>(pub Q);
Expand description

Query extractor

Allows to use a structure that implements DeserializeOwned to extract information easier from the query

use cataclysm::http::{Response, Query};
use serde::{Deserialize};

#[derive(Deserialize)]
struct QueryParams {
    name: String,
    last_name: Option<String>
}
 
async fn check_query(query: Query<QueryParams>) -> Response {
    log::info!("Http call from {}", query.into_inner().name);
    Response::ok()
}

Deserialization error will result always in a bad request response

Tuple Fields

0: Q

Implementations

Retrieves the inner instance of the generic type

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Extract function, constructs Self from the request

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.