pub struct OxideRouter<S = ()> { /* private fields */ }Expand description
Thin wrapper around axum::Router that provides a simplified registration API
with support for grouping, nesting, and merging.
Implementations§
Source§impl<S: Clone + Send + Sync + 'static> OxideRouter<S>
impl<S: Clone + Send + Sync + 'static> OxideRouter<S>
pub fn new() -> Self
Sourcepub fn from_router(router: Router<S>) -> Self
pub fn from_router(router: Router<S>) -> Self
Wrap an existing axum::Router in an OxideRouter.
Sourcepub fn nest_self(self, prefix: &str) -> Self
pub fn nest_self(self, prefix: &str) -> Self
Nest this router under a prefix, consuming and returning self.
Handles empty and “/” prefixes natively via merge (Axum 0.8 compatibility).
Sourcepub fn route<H, T>(self, method: Method, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
pub fn route<H, T>(self, method: Method, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
Register a handler for the given method and path.
pub fn get<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
pub fn post<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
pub fn put<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
pub fn delete<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
pub fn patch<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T, S>,
T: 'static,
Sourcepub fn merge(self, other: OxideRouter<S>) -> Self
pub fn merge(self, other: OxideRouter<S>) -> Self
Merge another OxideRouter into this one (flat merge, no prefix).
Sourcepub fn nest(self, prefix: &str, other: OxideRouter<S>) -> Self
pub fn nest(self, prefix: &str, other: OxideRouter<S>) -> Self
Nest a sub-router under the given prefix. Handles empty and “/” prefixes gracefully.
ⓘ
let api = OxideRouter::new()
.get("/users", list_users)
.post("/users", create_user);
let app_router = OxideRouter::new()
.nest("/api", api);
// produces: GET /api/users, POST /api/usersSourcepub fn into_inner(self) -> Router<S>
pub fn into_inner(self) -> Router<S>
Consume the wrapper and return the underlying axum::Router.
Auto Trait Implementations§
impl<S> Freeze for OxideRouter<S>
impl<S = ()> !RefUnwindSafe for OxideRouter<S>
impl<S> Send for OxideRouter<S>
impl<S> Sync for OxideRouter<S>
impl<S> Unpin for OxideRouter<S>
impl<S> UnsafeUnpin for OxideRouter<S>
impl<S = ()> !UnwindSafe for OxideRouter<S>
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