pub struct NoApi<T>(pub T);Available on crate feature
openapi only.Expand description
A wrapper type that allows using non-OpenAPI handlers and request parameters in OpenAPI routes.
If you need an extractor or a handler that does not implement
AsApiOperation/ApiOperationPart, you can wrap it in a NoApi to
indicate that it should just be ignored during OpenAPI generation.
§Examples
use cot::openapi::NoApi;
use cot::request::RequestHead;
use cot::request::extractors::FromRequestHead;
use cot::response::Response;
use cot::router::Route;
use cot::router::method::openapi::api_get;
struct MyExtractor;
impl FromRequestHead for MyExtractor {
async fn from_request_head(head: &RequestHead) -> cot::Result<Self> {
// ...
}
}
async fn handler(NoApi(extractor): NoApi<MyExtractor>) -> cot::Result<Response> {
// MyExtractor doesn't have to implement ApiOperationPart and
// doesn't show up in the OpenAPI spec
}
let router =
cot::router::Router::with_urls([Route::with_api_handler("/with_api", api_get(handler))]);use cot::openapi::NoApi;
use cot::response::Response;
use cot::router::Route;
use cot::router::method::openapi::api_get;
async fn handler_with_openapi() -> cot::Result<Response> {
// ...
}
async fn handler_without_openapi() -> cot::Result<Response> {
// ...
}
let router = cot::router::Router::with_urls([Route::with_api_handler(
"/with_api",
// POST will be ignored in OpenAPI spec
api_get(handler_with_openapi).post(NoApi(handler_without_openapi)),
)]);Tuple Fields§
§0: TTrait Implementations§
Source§impl<T> ApiOperationPart for NoApi<T>
impl<T> ApiOperationPart for NoApi<T>
Source§fn modify_api_operation(
operation: &mut Operation,
route_context: &RouteContext<'_>,
schema_generator: &mut SchemaGenerator,
)
fn modify_api_operation( operation: &mut Operation, route_context: &RouteContext<'_>, schema_generator: &mut SchemaGenerator, )
Modify the OpenAPI operation object. Read more
Source§impl<T> AsApiOperation for NoApi<T>
impl<T> AsApiOperation for NoApi<T>
Source§fn as_api_operation(
&self,
_route_context: &RouteContext<'_>,
_schema_generator: &mut SchemaGenerator,
) -> Option<Operation>
fn as_api_operation( &self, _route_context: &RouteContext<'_>, _schema_generator: &mut SchemaGenerator, ) -> Option<Operation>
Returns the OpenAPI operation for the route. Read more
impl<T: Copy> Copy for NoApi<T>
impl<T: Eq> Eq for NoApi<T>
Source§impl<T: FromRequest> FromRequest for NoApi<T>
impl<T: FromRequest> FromRequest for NoApi<T>
Source§async fn from_request(head: &RequestHead, body: Body) -> Result<Self>
async fn from_request(head: &RequestHead, body: Body) -> Result<Self>
Extracts data from the request. Read more
Source§impl<T: FromRequestHead> FromRequestHead for NoApi<T>
impl<T: FromRequestHead> FromRequestHead for NoApi<T>
Source§async fn from_request_head(head: &RequestHead) -> Result<Self>
async fn from_request_head(head: &RequestHead) -> Result<Self>
Extracts data from the request head. Read more
Source§impl<T: Ord> Ord for NoApi<T>
impl<T: Ord> Ord for NoApi<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for NoApi<T>
impl<T: PartialOrd> PartialOrd for NoApi<T>
Source§impl<HandlerParams, H> RequestHandler<HandlerParams> for NoApi<H>where
H: RequestHandler<HandlerParams>,
impl<HandlerParams, H> RequestHandler<HandlerParams> for NoApi<H>where
H: RequestHandler<HandlerParams>,
impl<T: PartialEq> StructuralPartialEq for NoApi<T>
Auto Trait Implementations§
impl<T> Freeze for NoApi<T>where
T: Freeze,
impl<T> RefUnwindSafe for NoApi<T>where
T: RefUnwindSafe,
impl<T> Send for NoApi<T>where
T: Send,
impl<T> Sync for NoApi<T>where
T: Sync,
impl<T> Unpin for NoApi<T>where
T: Unpin,
impl<T> UnsafeUnpin for NoApi<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for NoApi<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoField<Auto<T>> for T
impl<T> IntoField<Auto<T>> for T
Source§fn into_field(self) -> Auto<T>
fn into_field(self) -> Auto<T>
Available on crate feature
db only.Converts the type to the field type.