Skip to content

Commit

Permalink
reverse order of RequestParts::with_state args to match type params
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn committed Aug 17, 2022
1 parent 02a1f81 commit e211b15
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions axum-core/src/extract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<B> RequestParts<(), B> {
///
/// [`tower::Service`]: https://docs.rs/tower/lastest/tower/trait.Service.html
pub fn new(req: Request<B>) -> Self {
Self::with_state(req, ())
Self::with_state((), req)
}
}

Expand All @@ -106,7 +106,7 @@ impl<S, B> RequestParts<S, B> {
/// [`tower::Service`].
///
/// [`tower::Service`]: https://docs.rs/tower/lastest/tower/trait.Service.html
pub fn with_state(req: Request<B>, state: S) -> Self {
pub fn with_state(state: S, req: Request<B>) -> Self {
let (
http::request::Parts {
method,
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ where

fn call(self, state: S, req: http::Request<B>) -> Self::Future {
Box::pin(async move {
let mut req = RequestParts::with_state(req, state.clone());
let mut req = RequestParts::with_state(state.clone(), req);
match req.extract::<T>().await {
Ok(t) => self.handler.call(state, t).await,
Err(rejection) => rejection.into_response(),
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/handler/or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where

fn call(self, state: S, req: Request<B>) -> Self::Future {
Box::pin(async move {
let mut req = RequestParts::with_state(req, state.clone());
let mut req = RequestParts::with_state(state.clone(), req);

if let Ok(lt) = req.extract::<Lt>().await {
return self.lhs.call(state, lt).await;
Expand Down
2 changes: 1 addition & 1 deletion axum/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ macro_rules! impl_handler {

fn call(self, state: S, req: Request<B>) -> Self::Future {
Box::pin(async move {
let mut req = RequestParts::with_state(req, state);
let mut req = RequestParts::with_state(state, req);

$(
let $ty = match $ty::from_request(&mut req).await {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where

let request = buffer_request_body(request).await?;

*req = RequestParts::with_state(request, state);
*req = RequestParts::with_state(state, request);

Ok(Self)
}
Expand Down

0 comments on commit e211b15

Please sign in to comment.