add ability to hide individual routes
This commit is contained in:
parent
1e950b9efc
commit
26e7119768
5 changed files with 8 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Changelog
|
||||
|
||||
## Unreleased Changes
|
||||
- Add support for hiding individual routes from route list.
|
||||
|
||||
## v0.1.3 (2025-09-09)
|
||||
- Add support for having an array of paths match a single endpoint.
|
||||
|
|
|
|||
1
sg1.toml
1
sg1.toml
|
|
@ -18,6 +18,7 @@ from = "dod([fs][0-9]{2})e([0-9]{3})"
|
|||
# Capture groups can be replaced using numbered capture groups (`$1`, `$2`, ...)
|
||||
to = "https://dod.cptlobster.dev/episodes/$1/$2"
|
||||
using = "regex"
|
||||
hidden = true
|
||||
|
||||
[[routes]]
|
||||
from = "sub/path"
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ pub struct Route {
|
|||
from: Multiable<String>,
|
||||
to: String,
|
||||
#[serde(default)]
|
||||
using: MatcherType
|
||||
using: MatcherType,
|
||||
#[serde(default)]
|
||||
hidden: bool
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use rocket_dyn_templates::{Template, tera::Tera, context};
|
|||
async fn list_paths(cm: &State<ConfigManager>) -> Result<String, NoContent> {
|
||||
let config = cm.get().await;
|
||||
if config.hide_routes { return Err(NoContent) }
|
||||
let all_routes = config.routes.iter().flat_map(|r: &Route| r.src()).collect::<Vec<String>>();
|
||||
let all_routes = config.routes.iter().flat_map(|r: &Route| r.src()).filter(|r| !r.hidden).collect::<Vec<String>>();
|
||||
if all_routes.is_empty() { Err(NoContent) } else {
|
||||
Ok(all_routes.into_iter().map(|a| format!("/{}", a)).collect::<Vec<String>>().join("\n"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
</p>
|
||||
<ul>
|
||||
{%- for route in config.routes %}
|
||||
{%- if not route.hidden %}
|
||||
<li>
|
||||
{%- if route.using == "regex" %}
|
||||
{% if route.from is iterable %}
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
{%- endif %}
|
||||
({{ route.using }})
|
||||
</li>
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
<li>No routes configured.</li>
|
||||
{%- endfor %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue