Skip to content

Commit

Permalink
Rename structs and modules related to path parameters (#145)
Browse files Browse the repository at this point in the history
This PR aligns us with the terminology used in most web frameworks.
It should be the last public API cleanup ahead of the first beta
invites!
  • Loading branch information
LukeMathWalker committed Jan 3, 2024
1 parent 2bbde9e commit e18c421
Show file tree
Hide file tree
Showing 132 changed files with 785 additions and 866 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn route_request(
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route
.params
.into();
match route_id {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
32 changes: 11 additions & 21 deletions doc_examples/guide/request_data/json/project/server_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
32 changes: 11 additions & 21 deletions doc_examples/guide/request_data/path/project/server_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
32 changes: 11 additions & 21 deletions doc_examples/guide/request_data/query/project/server_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@ async fn route_request(
let matched_route = match server_state.router.at(&request_head.uri.path()) {
Ok(m) => m,
Err(_) => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter(vec![]).into();
return route_1::handler(&allowed_methods).await;
}
};
let route_id = matched_route.value;
#[allow(unused)]
let url_params: pavex::request::route::RawRouteParams<'_, '_> = matched_route
.params
.into();
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route.params.into();
match route_id {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_1::handler(&allowed_methods).await
}
0u32 => match &request_head.method {
&pavex::http::Method::GET => route_0::handler().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods =
pavex::router::MethodAllowList::from_iter([pavex::http::Method::GET]).into();
route_1::handler(&allowed_methods).await
}
}
},
i => unreachable!("Unknown route id: {}", i),
}
}
Expand All @@ -72,9 +64,7 @@ pub mod route_0 {
}
}
pub mod route_1 {
pub async fn handler(
v0: &pavex::router::AllowedMethods,
) -> pavex::response::Response {
pub async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::response::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
```rust title="src/raw_route_params/routes.rs"
use pavex::http::StatusCode;
use pavex::request::route::RawRouteParams;
use pavex::request::path::RawPathParams;
pub fn handler(params: &RawRouteParams) -> StatusCode {
pub fn handler(params: &RawPathParams) -> StatusCode {
for (name, value) in params.iter() {
println!("`{name}` was set to `{}`", value.as_str());
}
Expand Down
Loading

0 comments on commit e18c421

Please sign in to comment.