Don't default to basic-auth if it's enabled, yet require it to be specified

This commit is contained in:
Luke Parker
2023-11-06 10:31:26 -05:00
parent b9983bf133
commit b680bb532b
5 changed files with 117 additions and 66 deletions

View File

@@ -0,0 +1,21 @@
use hyper::{
StatusCode,
header::{HeaderValue, HeaderMap},
body::{Buf, Body},
};
use crate::Error;
#[derive(Debug)]
pub struct Response(pub(crate) hyper::Response<Body>);
impl Response {
pub fn status(&self) -> StatusCode {
self.0.status()
}
pub fn headers(&self) -> &HeaderMap<HeaderValue> {
self.0.headers()
}
pub async fn body(self) -> Result<impl std::io::Read, Error> {
hyper::body::aggregate(self.0.into_body()).await.map(Buf::reader).map_err(Error::Hyper)
}
}