Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMathWalker committed Jan 3, 2024
1 parent 82ab0f1 commit abecbc0
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 142 deletions.
4 changes: 2 additions & 2 deletions examples/realworld/api_server_sdk/blueprint.ron
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
constructor: (
callable: (
registered_at: "conduit_core",
import_path: "pavex::request::route::RouteParams::extract",
import_path: "pavex::request::path::PathParams::extract",
),
location: (
line: 42,
Expand All @@ -48,7 +48,7 @@
error_handler: Some((
callable: (
registered_at: "conduit_core",
import_path: "pavex::request::route::errors::ExtractRouteParamsError::into_response",
import_path: "pavex::request::path::errors::ExtractPathParamsError::into_response",
),
location: (
line: 46,
Expand Down
204 changes: 102 additions & 102 deletions examples/realworld/api_server_sdk/src/lib.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/realworld/conduit_core/src/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ fn register_common_constructors(bp: &mut Blueprint) {

// Route parameters
bp.constructor(
f!(pavex::request::route::RouteParams::extract),
f!(pavex::request::path::PathParams::extract),
Lifecycle::RequestScoped,
)
.error_handler(f!(
pavex::request::route::errors::ExtractRouteParamsError::into_response
pavex::request::path::errors::ExtractPathParamsError::into_response
));

// Json body
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct DeleteArticle {
pub slug: String,
}

pub fn delete_article(_params: RouteParams<DeleteArticle>) -> StatusCode {
pub fn delete_article(_params: PathParams<DeleteArticle>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct DeleteComment {
pub slug: String,
pub comment_id: u64,
}

pub fn delete_comment(_route: RouteParams<DeleteComment>) -> StatusCode {
pub fn delete_comment(_route: PathParams<DeleteComment>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Article;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct FavoriteArticle {
pub slug: String,
}
Expand All @@ -14,6 +14,6 @@ pub struct FavoriteArticleResponse {
pub article: Article,
}

pub fn favorite_article(_params: RouteParams<FavoriteArticle>) -> StatusCode {
pub fn favorite_article(_params: PathParams<FavoriteArticle>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Article;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct GetArticle {
pub slug: String,
}
Expand All @@ -14,6 +14,6 @@ pub struct GetArticleResponse {
pub article: Article,
}

pub fn get_article(_params: RouteParams<GetArticle>) -> StatusCode {
pub fn get_article(_params: PathParams<GetArticle>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Comment;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct ListComments {
pub slug: String,
}
Expand All @@ -14,6 +14,6 @@ pub struct ListCommentsResponse {
pub comments: Vec<Comment>,
}

pub fn list_comments(_route: RouteParams<ListComments>) -> StatusCode {
pub fn list_comments(_route: PathParams<ListComments>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use pavex::{
http::StatusCode,
request::{body::JsonBody, route::RouteParams},
request::{body::JsonBody, path::PathParams},
};

use crate::schemas::Comment;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct PublishCommentRoute {
pub slug: String,
}
Expand All @@ -30,7 +30,7 @@ pub struct PublishCommentResponse {
}

pub fn publish_comment(
_route: RouteParams<PublishCommentRoute>,
_route: PathParams<PublishCommentRoute>,
_body: JsonBody<PublishCommentBody>,
) -> StatusCode {
StatusCode::OK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Article;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct UnfavoriteArticle {
pub slug: String,
}
Expand All @@ -14,6 +14,6 @@ pub struct UnfavoriteArticleResponse {
pub article: Article,
}

pub fn unfavorite_article(_params: RouteParams<UnfavoriteArticle>) -> StatusCode {
pub fn unfavorite_article(_params: PathParams<UnfavoriteArticle>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pavex::{
http::StatusCode,
request::{body::JsonBody, route::RouteParams},
request::{body::JsonBody, path::PathParams},
};

use crate::schemas::Article;
Expand All @@ -14,7 +14,7 @@ pub struct UpdateArticleBody {
}

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct UpdateArticleRoute {
pub slug: String,
}
Expand All @@ -26,7 +26,7 @@ pub struct UpdateArticleResponse {
}

pub fn update_article(
_params: RouteParams<UpdateArticleRoute>,
_params: PathParams<UpdateArticleRoute>,
_body: JsonBody<UpdateArticleBody>,
) -> StatusCode {
StatusCode::OK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Profile;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct FollowProfile {
pub username: String,
}
Expand All @@ -14,6 +14,6 @@ pub struct FollowProfileResponse {
pub profile: Profile,
}

pub fn follow_profile(_params: RouteParams<FollowProfile>) -> StatusCode {
pub fn follow_profile(_params: PathParams<FollowProfile>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Profile;

#[derive(Debug)]
#[RouteParams]
#[PathParams]
pub struct GetProfile {
pub username: String,
}
Expand All @@ -14,6 +14,6 @@ pub struct GetProfileResponse {
pub profile: Profile,
}

pub fn get_profile(_params: RouteParams<GetProfile>) -> StatusCode {
pub fn get_profile(_params: PathParams<GetProfile>) -> StatusCode {
StatusCode::OK
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use pavex::{http::StatusCode, request::route::RouteParams};
use pavex::{http::StatusCode, request::path::PathParams};

use crate::schemas::Profile;

#[RouteParams]
#[PathParams]
#[derive(Debug)]
pub struct UnfollowProfile {
pub username: String,
Expand All @@ -14,6 +14,6 @@ pub struct UnfollowProfileResponse {
pub profile: Profile,
}

pub fn unfollow_profile(_params: RouteParams<UnfollowProfile>) -> StatusCode {
pub fn unfollow_profile(_params: PathParams<UnfollowProfile>) -> StatusCode {
StatusCode::OK
}
4 changes: 2 additions & 2 deletions examples/realworld/conduit_core/src/telemetry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pavex::http::Version;
use pavex::middleware::Next;
use pavex::request::route::MatchedRouteTemplate;
use pavex::request::path::MatchedPathPattern;
use pavex::request::RequestHead;
use pavex::response::Response;
use std::borrow::Cow;
Expand All @@ -24,7 +24,7 @@ impl RootSpan {
///
/// We follow OpenTelemetry's HTTP semantic conventions as closely as
/// possible for field naming.
pub fn new(request_head: &RequestHead, matched_route: MatchedRouteTemplate) -> Self {
pub fn new(request_head: &RequestHead, matched_route: MatchedPathPattern) -> Self {
let user_agent = request_head
.headers
.get("User-Agent")
Expand Down
2 changes: 1 addition & 1 deletion examples/skeleton/app_server_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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

0 comments on commit abecbc0

Please sign in to comment.