mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-05-10 00:20:43 +00:00
Custom Endpoints
This commit is contained in:
parent
002cfb1b4d
commit
5261aa9931
28 changed files with 524 additions and 46 deletions
|
@ -83,10 +83,14 @@ macro_rules! implOpenapiRouter {
|
|||
}
|
||||
|
||||
static URI_PLACEHOLDER_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r#"(^|/):(?P<name>[^/]+)(/|$)"#).unwrap());
|
||||
Lazy::new(|| Regex::new(r#"(?P<prefix>^|/):(?P<name>[^/]+)(?P<suffix>/|$)"#).unwrap());
|
||||
let uri: &str = &E::uri();
|
||||
let uri =
|
||||
URI_PLACEHOLDER_REGEX.replace_all(uri, |captures: &Captures<'_>| format!("{{{}}}", &captures["name"]));
|
||||
let uri = URI_PLACEHOLDER_REGEX.replace_all(uri, |captures: &Captures<'_>| {
|
||||
format!(
|
||||
"{}{{{}}}{}",
|
||||
&captures["prefix"], &captures["name"], &captures["suffix"]
|
||||
)
|
||||
});
|
||||
let path = if uri.is_empty() {
|
||||
format!("{}/{}", self.0.scope.unwrap_or_default(), self.1)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue