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 set_error_handler(
&mut self,
handler: Box<dyn Fn(Box<dyn Error>, &Request, &mut Response)>,
)
pub fn set_error_handler( &mut self, handler: Box<dyn Fn(Box<dyn Error>, &Request, &mut Response)>, )
Set up the Error Handling Solution for that App.
If there are no Error Handler present by default,
framework will Catch the error and print it to the stderr
and return a 500
Status code response back to the client
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