1 unstable release
new 0.1.0 | Nov 11, 2024 |
---|
#1977 in Web programming
121 downloads per month
Used in tunnelbana
11KB
173 lines
tunnelbana-hidepaths
Hide specific paths in tower services by sending them to a 404 service.
lib.rs
:
tunnelbana-hidepaths
Hide specific paths in tower services by sending them to a 404 service.
Part of the tunnelbana project.
Example
use tower_http::services::ServeDir;
use tower::{ServiceBuilder, ServiceExt};
use http::Response;
use tunnelbana_hidepaths::HidePathsLayer;
let hidepaths_middleware = HidePathsLayer::builder()
.hide("/_redirects")
.hide_all(["/.htaccess", "/.well-known/{*hide}"])
.build()
.expect("Failed to build path hide router");
let serve_dir = ServeDir::new("/var/www/html").append_index_html_on_directories(true);
let service = ServiceBuilder::new()
.layer(hidepaths_middleware)
.service(serve_dir);
Dependencies
~2.2–3MB
~55K SLoC