Log what HTTP method was wrong

This commit is contained in:
xmppftw 2024-08-07 10:51:31 +02:00 committed by Maxime “pep” Buquet
parent ca7a5a8090
commit f9e6b91451
2 changed files with 3 additions and 3 deletions

View file

@ -23,7 +23,7 @@ use hmac::digest::InvalidLength as HmacInvalidLength;
#[derive(Debug)]
pub(crate) enum Error {
MethodMismatch,
MethodMismatch(hyper::Method),
InvalidSecret,
InvalidContentType,
InvalidSignature,
@ -43,7 +43,7 @@ impl StdError for Error {}
impl std::fmt::Display for Error {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Error::MethodMismatch => write!(fmt, "the method is invalid"),
Error::MethodMismatch(method) => write!(fmt, "method is invalid {method}, expected POST"),
Error::InvalidSecret => write!(fmt, "the secret is invalid"),
Error::InvalidContentType => write!(fmt, "the content-type is invalid"),
Error::InvalidSignature => write!(fmt, "the signature is invalid"),

View file

@ -44,7 +44,7 @@ fn error_res<E: std::fmt::Debug>(e: E) -> Result<Response<Full<Bytes>>, Infallib
async fn hooks_inner(req: Request<Incoming>, secret: &str) -> Result<Hook, Error> {
match req.method() {
&Method::POST => (),
_ => return Err(Error::MethodMismatch),
_ => return Err(Error::MethodMismatch(req.method().clone())),
}
debug!("Headers: {:?}", req.headers());