pub struct App { /* private fields */ }Expand description
A Feather application.
Implementations§
Source§impl App
impl App
Sourcepub fn context(&mut self) -> &mut AppContext
pub fn context(&mut self) -> &mut AppContext
Returns a Handle to the AppContext inside the App AppContext is Used for App wide state managment
Sourcepub fn route<M: Middleware + 'static>(
&mut self,
method: Method,
path: impl Into<Cow<'static, str>>,
middleware: M,
)
pub fn route<M: Middleware + 'static>( &mut self, method: Method, path: impl Into<Cow<'static, str>>, middleware: M, )
Add a route to the application.
Every Route Returns A MiddlewareResult to control the flow of your application.
Sourcepub fn use_middleware(&mut self, middleware: impl Middleware + 'static)
pub fn use_middleware(&mut self, middleware: impl Middleware + 'static)
Add a global middleware to the application that will be applied to all routes.
Sourcepub fn get<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn get<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn post<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn post<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn put<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn put<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn delete<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn delete<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn patch<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn patch<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn head<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn head<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn options<M: Middleware + 'static>(
&mut self,
path: impl Into<String>,
middleware: M,
)
pub fn options<M: Middleware + 'static>( &mut self, path: impl Into<String>, middleware: M, )
Adds a route to the application for the HTTP method.
Sourcepub fn listen(&mut self, address: impl ToSocketAddrs + Display)
pub fn listen(&mut self, address: impl ToSocketAddrs + Display)
Start the application and listen for incoming requests on the given address. Blocks the current thread until the server is stopped.
§Panics
Panics if the server fails to start