Concentrate configuration content parsing in syntax::serial

Fixes some pages not having parsed input by making it much harder to
construct a config with unparsed text, which is something you basically
never want. The parsing now happens much earlier and consumers don't
need to remember to parse the configuration anymore.

Fixes a possible stack overflow due to parsing and configuration
depending on each other.

This commit also has dependencies updates and minor justfile tweaks.
This commit is contained in:
Juno Takano 2025-12-28 05:16:22 -03:00
commit 7300a29b67
12 changed files with 142 additions and 132 deletions

View file

@ -75,7 +75,7 @@ mod tests {
let graph = Graph {
meta: Meta {
config: config
.map(|c| c.to_owned())
.map(std::borrow::ToOwned::to_owned)
.unwrap_or(default_graph.meta.config),
..default_graph.meta
},
@ -121,10 +121,8 @@ mod tests {
#[tokio::test]
async fn no_about_page() {
let config = Config {
about: false,
..populate_graph().meta.config
};
let mut config = Config::new();
config.about = false;
let response = request("/about", Some(&config)).await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
@ -132,10 +130,8 @@ mod tests {
#[tokio::test]
async fn no_tree_page() {
let config = Config {
tree: false,
..populate_graph().meta.config
};
let mut config = Config::new();
config.tree = false;
let response = request("/tree", Some(&config)).await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
@ -143,10 +139,8 @@ mod tests {
#[tokio::test]
async fn no_toml_raw_graph() {
let config = Config {
raw_toml: false,
..populate_graph().meta.config
};
let mut config = Config::new();
config.raw_toml = false;
let response = request("/graph/toml", Some(&config)).await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
@ -154,10 +148,8 @@ mod tests {
#[tokio::test]
async fn no_json_raw_graph() {
let config = Config {
raw_json: false,
..populate_graph().meta.config
};
let mut config = Config::new();
config.raw_json = false;
let response = request("/graph/json", Some(&config)).await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
@ -165,10 +157,8 @@ mod tests {
#[tokio::test]
async fn no_raw_graph() {
let config = Config {
raw: false,
..populate_graph().meta.config
};
let mut config = Config::new();
config.raw = false;
let toml_response = request("/graph/toml", Some(&config)).await;
assert_eq!(toml_response.status(), StatusCode::NOT_FOUND);