TOWER ALLOWED HOSTS
Project status & info:
| License | Crates Version | Docs |
|---|---|---|
Tower service which limits request from only hosts
Add as dependencies
Edit Cargo.toml file to add tower_allowed_hosts as dependencies
[]
= "0.6.0"
Usage
To use non regex based hosts you can use
let tower_layer = default.extend;
If you need to use wildcard based host matching you need to enable wildcard feature for crate than you can use
let tower_layer = default.extend_wildcard;
If you need to use regex based host matching you need to enable regex feature for crate than you can use
let tower_layer = default.extend_regex;
After creation of layer you can use layer in library which supports tower as component
For example to use tower allowed hosts in axum you also needs to add HandleErrorLayer so error gets handled properly
use ;
use ServiceBuilder;
use AllowedHostLayer;
async
There is also extension added after successfully parsing allowed host and allowing host which can be access using
tower_allowed_hosts::Host struct Extension