Skip to content

Commit

Permalink
fix: remove Server header from responses
Browse files Browse the repository at this point in the history
  • Loading branch information
cailloumajor committed Jun 21, 2022
1 parent 16187bc commit 415dab1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use notify::{recommended_watcher, Event, RecursiveMode, Watcher};
use signal_hook::consts::TERM_SIGNALS;
use signal_hook::low_level::signal_name;
use signal_hook_async_std::Signals;
use trillium::{Handler, State};
use trillium::{Conn, Handler, KnownHeaderName, State};
use trillium_async_std::Stopper;
use trillium_compression::Compression;
use trillium_router::Router;
Expand Down Expand Up @@ -84,6 +84,11 @@ async fn handle_notify(
eprintln!("from=handle_notify status=exiting");
}

async fn remove_server_header(mut conn: Conn) -> Conn {
conn.headers_mut().remove(KnownHeaderName::Server);
conn
}

fn router() -> impl Handler {
Router::new()
.get("/config/*", config_handler)
Expand Down Expand Up @@ -137,6 +142,7 @@ async fn main() -> anyhow::Result<()> {
.run_async((
State::new(AppState { static_config }),
Compression::new(),
remove_server_header,
router(),
))
.await;
Expand Down

0 comments on commit 415dab1

Please sign in to comment.