Log what HTTP method was wrong
This commit is contained in:
parent
ca7a5a8090
commit
f9e6b91451
2 changed files with 3 additions and 3 deletions
|
@ -23,7 +23,7 @@ use hmac::digest::InvalidLength as HmacInvalidLength;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) enum Error {
|
pub(crate) enum Error {
|
||||||
MethodMismatch,
|
MethodMismatch(hyper::Method),
|
||||||
InvalidSecret,
|
InvalidSecret,
|
||||||
InvalidContentType,
|
InvalidContentType,
|
||||||
InvalidSignature,
|
InvalidSignature,
|
||||||
|
@ -43,7 +43,7 @@ impl StdError for Error {}
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
match self {
|
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::InvalidSecret => write!(fmt, "the secret is invalid"),
|
||||||
Error::InvalidContentType => write!(fmt, "the content-type is invalid"),
|
Error::InvalidContentType => write!(fmt, "the content-type is invalid"),
|
||||||
Error::InvalidSignature => write!(fmt, "the signature is invalid"),
|
Error::InvalidSignature => write!(fmt, "the signature is invalid"),
|
||||||
|
|
|
@ -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> {
|
async fn hooks_inner(req: Request<Incoming>, secret: &str) -> Result<Hook, Error> {
|
||||||
match req.method() {
|
match req.method() {
|
||||||
&Method::POST => (),
|
&Method::POST => (),
|
||||||
_ => return Err(Error::MethodMismatch),
|
_ => return Err(Error::MethodMismatch(req.method().clone())),
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Headers: {:?}", req.headers());
|
debug!("Headers: {:?}", req.headers());
|
||||||
|
|
Loading…
Reference in a new issue