MethodRouter

Struct MethodRouter 

Source
pub struct MethodRouter<S = (), E = Infallible> { /* private fields */ }
Expand description

Drop-in replacement for axum::routing::MethodRouter, which supports OpenAPI definitions of handlers or services.

Implementations§

Source§

impl<S> MethodRouter<S, Infallible>
where S: Clone,

Source

pub fn on<I, H, T>(self, filter: MethodFilter, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn delete<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn get<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn head<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn options<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn patch<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn post<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn put<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn trace<I, H, T>(self, handler: I) -> Self
where I: Into<HandlerWithOperation<H, T, S>>, H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source

pub fn fallback<H, T>(self, handler: H) -> Self
where H: Handler<T, S>, T: 'static, S: Send + Sync + 'static,

Source§

impl<S, E> MethodRouter<S, E>
where S: Clone,

Source

pub fn new() -> Self

Source

pub fn into_axum(self) -> AxumMethodRouter<S, E>

Convert method router into axum::routing::MethodRouter, dropping related OpenAPI definitions.

Source

pub fn on_service<I, Svc>(self, filter: MethodFilter, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn delete_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn get_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn head_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn options_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn patch_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn post_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn put_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn trace_service<I, Svc>(self, svc: I) -> Self
where I: Into<ServiceWithOperation<Svc, E>>, Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn fallback_service<Svc>(self, svc: Svc) -> Self
where Svc: Service<Request, Error = E> + Clone + Send + Sync + 'static, Svc::Response: IntoResponse + 'static, Svc::Future: Send + 'static,

Source

pub fn layer<L, NewError>(self, layer: L) -> MethodRouter<S, NewError>
where L: Layer<Route<E>> + Clone + Send + Sync + 'static, L::Service: Service<Request> + Clone + Send + Sync + 'static, <L::Service as Service<Request>>::Response: IntoResponse + 'static, <L::Service as Service<Request>>::Error: Into<NewError> + 'static, <L::Service as Service<Request>>::Future: Send + 'static, E: 'static, S: 'static, NewError: 'static,

Source

pub fn route_layer<L>(self, layer: L) -> MethodRouter<S, E>
where L: Layer<Route<E>> + Clone + Send + Sync + 'static, L::Service: Service<Request, Error = E> + Clone + Send + Sync + 'static, <L::Service as Service<Request>>::Response: IntoResponse + 'static, <L::Service as Service<Request>>::Future: Send + 'static, E: 'static, S: 'static,

Source

pub fn merge(self, other: MethodRouter<S, E>) -> Self

Source

pub fn handle_error<F, T>(self, f: F) -> MethodRouter<S, Infallible>
where F: Clone + Send + Sync + 'static, HandleError<Route<E>, F, T>: Service<Request, Error = Infallible>, <HandleError<Route<E>, F, T> as Service<Request>>::Future: Send, <HandleError<Route<E>, F, T> as Service<Request>>::Response: IntoResponse + Send, T: 'static, E: 'static, S: 'static,

Source

pub fn with_state<S2>(self, state: S) -> MethodRouter<S2, E>

Trait Implementations§

Source§

impl<S, E> Debug for MethodRouter<S, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S, E> Default for MethodRouter<S, E>
where S: Clone,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S, E> From<MethodRouter<S, E>> for MethodRouter<S, E>

Source§

fn from(value: AxumMethodRouter<S, E>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<S, E> Freeze for MethodRouter<S, E>

§

impl<S = (), E = Infallible> !RefUnwindSafe for MethodRouter<S, E>

§

impl<S, E> Send for MethodRouter<S, E>

§

impl<S, E> Sync for MethodRouter<S, E>

§

impl<S, E> Unpin for MethodRouter<S, E>

§

impl<S = (), E = Infallible> !UnwindSafe for MethodRouter<S, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,