Skip to content

Commit d02e473

Browse files
pflanzesyphar
authored andcommitted
preparations for API to request rebuild of a crate version
- web: `axum_cached_redirect`: change return type to be concrete - web/routes: add `post_internal` - test: add `TestFrontent::post`
1 parent 4fb2d5d commit d02e473

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/test/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,12 @@ impl TestFrontend {
777777
self.client.request(Method::GET, url)
778778
}
779779

780+
pub(crate) fn post(&self, url: &str) -> RequestBuilder {
781+
let url = self.build_url(url);
782+
debug!("posting {url}");
783+
self.client.request(Method::POST, url)
784+
}
785+
780786
pub(crate) fn get_no_redirect(&self, url: &str) -> RequestBuilder {
781787
let url = self.build_url(url);
782788
debug!("getting {url} (no redirects)");

src/web/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ where
581581
fn axum_cached_redirect<U>(
582582
uri: U,
583583
cache_policy: cache::CachePolicy,
584-
) -> Result<impl IntoResponse, Error>
584+
) -> Result<axum::response::Response, Error>
585585
where
586586
U: TryInto<http::Uri> + std::fmt::Debug,
587587
<U as TryInto<http::Uri>>::Error: std::fmt::Debug,

src/web/routes.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use axum::{
66
handler::Handler as AxumHandler,
77
middleware::{self, Next},
88
response::{IntoResponse, Redirect},
9-
routing::{get, MethodRouter},
9+
routing::{get, post, MethodRouter},
1010
Router as AxumRouter,
1111
};
1212
use axum_extra::routing::RouterExt;
@@ -39,6 +39,18 @@ where
3939
}))
4040
}
4141

42+
#[instrument(skip_all)]
43+
fn post_internal<H, T, S>(handler: H) -> MethodRouter<S, Infallible>
44+
where
45+
H: AxumHandler<T, S>,
46+
T: 'static,
47+
S: Clone + Send + Sync + 'static,
48+
{
49+
post(handler).route_layer(middleware::from_fn(|request, next| async {
50+
request_recorder(request, next, None).await
51+
}))
52+
}
53+
4254
#[instrument(skip_all)]
4355
fn get_rustdoc<H, T, S>(handler: H) -> MethodRouter<S, Infallible>
4456
where

0 commit comments

Comments
 (0)