Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Jul 29, 2024
1 parent 8c93cda commit 3da4628
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/core/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl PathParams {
self.greedy
}
/// Get the last param starts with '*', for example: <**rest>, <*?rest>.
pub fn star(&self) -> Option<&str> {
pub fn tail(&self) -> Option<&str> {
if self.greedy {
self.inner.last().map(|(_, v)| &**v)
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/oapi/src/swagger_ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl Handler for SwaggerUi {
redirect_to_dir_url(req.uri(), res);
return;
}
let Some(path) = req.params().star() else {
let Some(path) = req.params().tail() else {
res.render(StatusError::not_found().detail("The router params is incorrect. The params should ending with a wildcard."));
return;
};
Expand Down
2 changes: 1 addition & 1 deletion crates/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub type UrlPartGetter = Box<dyn Fn(&Request, &Depot) -> Option<String> + Send +
/// This getter will get the last param as the rest url path from request.
/// In most case you should use wildcard param, like `<**rest>`, `<*+rest>`.
pub fn default_url_path_getter(req: &Request, _depot: &Depot) -> Option<String> {
req.params().star().map(encode_url_path)
req.params().tail().map(encode_url_path)
}
/// Default url query getter. This getter just return the query string from request uri.
pub fn default_url_query_getter(req: &Request, _depot: &Depot) -> Option<String> {
Expand Down
2 changes: 1 addition & 1 deletion crates/serve-static/src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl DirInfo {
impl Handler for StaticDir {
async fn handle(&self, req: &mut Request, _depot: &mut Depot, res: &mut Response, _ctrl: &mut FlowCtrl) {
let req_path = req.uri().path();
let rel_path = if let Some(rest) = req.params().star() {
let rel_path = if let Some(rest) = req.params().tail() {
rest
} else {
&*decode_url_path_safely(req_path)
Expand Down
2 changes: 1 addition & 1 deletion crates/serve-static/src/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
T: RustEmbed + Send + Sync + 'static,
{
async fn handle(&self, req: &mut Request, _depot: &mut Depot, res: &mut Response, _ctrl: &mut FlowCtrl) {
let req_path = if let Some(rest) = req.params().star() {
let req_path = if let Some(rest) = req.params().tail() {
rest
} else {
&*decode_url_path_safely(req.uri().path())
Expand Down

0 comments on commit 3da4628

Please sign in to comment.