Expand description
§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);Structs§
- Default
NotFound Future - Future type which returns an empty HTTP 404.
- Default
NotFound Service - Unconfigurable service which returns HTTP 404s with no body.
- Hide
Path - A wrapper service which forwards to one of two inner services based on if the requested path is contained within its internal router.
- Hide
Paths Layer - A
tower::Layerfor use with atower::ServiceBuilderto reply with a fallback service to any routes found internally. - Hide
Paths Layer Builder - Build a
matchit::Routerof paths which should be routed to the not found service. - Hide
Paths Layer Builder Error
Enums§
- Insert
Error - Represents errors that can occur when inserting a new route.
- Response
Future - Future which always delegates the whole response to either the default service, or a not-found fallback, and returns the service response unmodified.