pub struct RouteEntry {
pub method: Method,
pub path: String,
/* private fields */
}Expand description
A registered route with its handler.
Fields§
§method: MethodThe HTTP method for this route.
path: StringThe path pattern for this route.
Implementations§
Source§impl RouteEntry
impl RouteEntry
Sourcepub fn new<H, Fut>(method: Method, path: impl Into<String>, handler: H) -> Self
pub fn new<H, Fut>(method: Method, path: impl Into<String>, handler: H) -> Self
Creates a new route entry.
Note: The handler’s returned future must be 'static, meaning it should not
hold references to the context or request beyond the call. If you need to
borrow from them, clone the data you need first.
Sourcepub fn from_route<H, Fut>(route: Route, handler: H) -> Self
pub fn from_route<H, Fut>(route: Route, handler: H) -> Self
Creates a new route entry from a fastapi_router::Route metadata object.
This is the preferred constructor for proc-macro generated routes, since it preserves OpenAPI metadata (operation_id, tags, request body, etc).
Sourcepub fn route_meta(&self) -> Option<&Route>
pub fn route_meta(&self) -> Option<&Route>
Returns the preserved route metadata, if any.
Sourcepub async fn call(&self, ctx: &RequestContext, req: &mut Request) -> Response
pub async fn call(&self, ctx: &RequestContext, req: &mut Request) -> Response
Calls the handler with the given context and request.
Trait Implementations§
Source§impl Clone for RouteEntry
impl Clone for RouteEntry
Source§fn clone(&self) -> RouteEntry
fn clone(&self) -> RouteEntry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RouteEntry
impl !RefUnwindSafe for RouteEntry
impl Send for RouteEntry
impl Sync for RouteEntry
impl Unpin for RouteEntry
impl !UnwindSafe for RouteEntry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).