adding responder

This commit is contained in:
2025-01-16 20:04:13 +01:00
parent f89c1582f3
commit f5f3ee67a5
3 changed files with 18 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
use crate::{builder::ServerBuilder, config::ServerConfig};
use crate::{builder::ServerBuilder, config::ServerConfig, responder::Responder};
use http1::Builder;
use http_body_util::Full;
use hyper::{body::Incoming, server::conn::http1, service::service_fn, Request, Response};
@@ -58,10 +58,7 @@ impl Server {
if config.is_req_authorized(&req) {
handler(req).await
} else {
Ok(Response::builder()
.status(401)
.body(Full::new(Bytes::from("Unauthorized")))
.unwrap())
Responder::unathorized()
}
}
}),