ntex-remove-trailing-slash

Crates.iontex-remove-trailing-slash
lib.rsntex-remove-trailing-slash
version0.1.0
created_at2025-06-01 07:25:52.767338+00
updated_at2025-06-01 07:25:52.767338+00
descriptionRemoving trailing slash on ntex Framework, inspired by actix's
homepage
repositoryhttps://github.com/ir1keren/ntex-remove-trailing-slash.git
max_upload_size
id1696932
size29,476
Irwan Darmawan (ir1keren)

documentation

README

ntex-remove-trailing-slash

Removing trailing slash on ntex Framework

Usage

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" }

Example

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())
}
Commit count: 0

cargo fmt