pub struct RouteDefinition {
pub method: HttpMethod,
pub path: String,
pub handler: String,
pub middleware: Vec<String>,
pub description: Option<String>,
pub tags: Vec<String>,
pub parameters: Vec<RouteParameter>,
}
Expand description
Route definition for module routing
Fields§
§method: HttpMethod
§path: String
§handler: String
§middleware: Vec<String>
§description: Option<String>
§parameters: Vec<RouteParameter>
Implementations§
Source§impl RouteDefinition
impl RouteDefinition
Sourcepub fn new(
method: HttpMethod,
path: impl Into<String>,
handler: impl Into<String>,
) -> Self
pub fn new( method: HttpMethod, path: impl Into<String>, handler: impl Into<String>, ) -> Self
Create a new route definition
Sourcepub fn with_middleware(self, middleware: Vec<String>) -> Self
pub fn with_middleware(self, middleware: Vec<String>) -> Self
Add middleware to the route
Sourcepub fn add_middleware(self, middleware: impl Into<String>) -> Self
pub fn add_middleware(self, middleware: impl Into<String>) -> Self
Add a single middleware
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set route description
Add tags to the route
Sourcepub fn with_parameters(self, parameters: Vec<RouteParameter>) -> Self
pub fn with_parameters(self, parameters: Vec<RouteParameter>) -> Self
Add parameters to the route
Sourcepub fn add_parameter(self, parameter: RouteParameter) -> Self
pub fn add_parameter(self, parameter: RouteParameter) -> Self
Add a single parameter
Sourcepub fn path_pattern(&self) -> String
pub fn path_pattern(&self) -> String
Get route path with parameter placeholders
Sourcepub fn matches(&self, method: &HttpMethod, path: &str) -> bool
pub fn matches(&self, method: &HttpMethod, path: &str) -> bool
Check if route matches a given path and method
Trait Implementations§
Source§impl Clone for RouteDefinition
impl Clone for RouteDefinition
Source§fn clone(&self) -> RouteDefinition
fn clone(&self) -> RouteDefinition
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 RouteDefinition
impl RefUnwindSafe for RouteDefinition
impl Send for RouteDefinition
impl Sync for RouteDefinition
impl Unpin for RouteDefinition
impl UnwindSafe for RouteDefinition
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