Crate tunnelbana_hidepaths

Crate tunnelbana_hidepaths 

Source
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§

DefaultNotFoundFuture
Future type which returns an empty HTTP 404.
DefaultNotFoundService
Unconfigurable service which returns HTTP 404s with no body.
HidePath
A wrapper service which forwards to one of two inner services based on if the requested path is contained within its internal router.
HidePathsLayer
A tower::Layer for use with a tower::ServiceBuilder to reply with a fallback service to any routes found internally.
HidePathsLayerBuilder
Build a matchit::Router of paths which should be routed to the not found service.
HidePathsLayerBuilderError

Enums§

InsertError
Represents errors that can occur when inserting a new route.
ResponseFuture
Future which always delegates the whole response to either the default service, or a not-found fallback, and returns the service response unmodified.