Skip to content

Commit

Permalink
Reject incorrect methods
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Sep 17, 2024
1 parent 7da5256 commit ceabdbf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ macro_rules! command {
async move {
let (mut parts, body) = req.into_parts();

if parts.method != <Self as $crate::api::Command>::HTTP_METHOD {
return Err(http::StatusCode::METHOD_NOT_ALLOWED.into_response());
}

let Path(($($field_name,)*)) = Path::<($(segments::[<$field_name:camel>],)*)>::from_request_parts(&mut parts, state)
.await.map_err(IntoResponse::into_response)?;

Expand Down

0 comments on commit ceabdbf

Please sign in to comment.