| Crates.io | ntex-remove-trailing-slash |
| lib.rs | ntex-remove-trailing-slash |
| version | 0.1.0 |
| created_at | 2025-06-01 07:25:52.767338+00 |
| updated_at | 2025-06-01 07:25:52.767338+00 |
| description | Removing trailing slash on ntex Framework, inspired by actix's |
| homepage | |
| repository | https://github.com/ir1keren/ntex-remove-trailing-slash.git |
| max_upload_size | |
| id | 1696932 |
| size | 29,476 |
Removing trailing slash on ntex Framework
As in the description, this crate provides a middleware for the ntex framework that removes trailing slashes from incoming requests. So it will be possible to access the same resource with or without a trailing slash.
This is useful for creating a consistent API where the presence or absence of a trailing slash does not affect the resource being accessed.
So, GET /api/resource/ and GET /api/resource will both return the same resource.
Inspired by actix's.
[dependencies]
ntex-remove-trailing-slash = { version = "0.1.0" }
use ntex_remove_trailing_slash::RemoveTrailingSlash;
use ntex::{server::Server, web::{error::ErrorInternalServerError, route, scope, types::JsonConfig, App, HttpServer}};
pub fn create_new_www()->std::io::Result<Server>
{
let app=HttpServer::new(|| {
let ts=RemoveTrailingSlash::default();
App::new()
.wrap(ts)
});
app.bind(("0.0.0.0",80)?;
Ok(app.run())
}