pub trait NgynHttpEngine: NgynPlatform {
// Provided methods
fn route(
&mut self,
path: &str,
method: Method,
handler: impl Into<RouteHandler>,
) { ... }
fn get(&mut self, path: &str, handler: impl Into<RouteHandler>) { ... }
fn post(&mut self, path: &str, handler: impl Into<RouteHandler>) { ... }
fn put(&mut self, path: &str, handler: impl Into<RouteHandler>) { ... }
fn delete(&mut self, path: &str, handler: impl Into<RouteHandler>) { ... }
fn patch(&mut self, path: &str, handler: impl Into<RouteHandler>) { ... }
fn head(&mut self, path: &str, handler: impl Into<RouteHandler>) { ... }
fn use_static(&mut self, path_buf: PathBuf) -> Result<()> { ... }
}
Provided Methods§
Sourcefn get(&mut self, path: &str, handler: impl Into<RouteHandler>)
fn get(&mut self, path: &str, handler: impl Into<RouteHandler>)
Adds a new route to the NgynApplication
with the Method::Get
.
Sourcefn post(&mut self, path: &str, handler: impl Into<RouteHandler>)
fn post(&mut self, path: &str, handler: impl Into<RouteHandler>)
Adds a new route to the NgynApplication
with the Method::Post
.
Sourcefn put(&mut self, path: &str, handler: impl Into<RouteHandler>)
fn put(&mut self, path: &str, handler: impl Into<RouteHandler>)
Adds a new route to the NgynApplication
with the Method::Put
.
Sourcefn delete(&mut self, path: &str, handler: impl Into<RouteHandler>)
fn delete(&mut self, path: &str, handler: impl Into<RouteHandler>)
Adds a new route to the NgynApplication
with the Method::Delete
.
Sourcefn patch(&mut self, path: &str, handler: impl Into<RouteHandler>)
fn patch(&mut self, path: &str, handler: impl Into<RouteHandler>)
Adds a new route to the NgynApplication
with the Method::Patch
.
Sourcefn head(&mut self, path: &str, handler: impl Into<RouteHandler>)
fn head(&mut self, path: &str, handler: impl Into<RouteHandler>)
Adds a new route to the NgynApplication
with the Method::Head
.
Sourcefn use_static(&mut self, path_buf: PathBuf) -> Result<()>
fn use_static(&mut self, path_buf: PathBuf) -> Result<()>
Sets up static file routes.
This is great for apps tha would want to output files in a specific folder.
For instance, a public
directory can be set up and include all files in the directory
The behavior of use_static
in ngyn is different from other frameworks.
- You can call it multiple times, each call registers a new set of routes
- The files in
path_buf
folder aren’t embedded into your binary and must be copied to the location of your binary
§Arguments
path_buf
- static folder, relative to Cargo.toml in dev, and the binary in release
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.