diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-03-18 04:10:30 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-03-18 04:10:30 -0400 |
| commit | 9dc056dc405ec2c23b3e802624c5596f518608d3 (patch) | |
| tree | 2512df7de25e74b5fcb698486a41a2fef2286c0b /src/Main.c | |
| parent | e1ad06ea257a60e90ea0877f5c12a289b541aa55 (diff) | |
| download | omnisearch-9dc056dc405ec2c23b3e802624c5596f518608d3.tar.gz | |
feature: moved domain for opensearch to config
Diffstat (limited to 'src/Main.c')
| -rw-r--r-- | src/Main.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -15,10 +15,18 @@ #include "Routes/Search.h" #include "Scraping/Scraping.h" +Config global_config; + int handle_opensearch(UrlParams *params) { (void)params; - serve_static_file_with_mime("opensearch.xml", - "application/opensearchdescription+xml"); + extern Config global_config; + TemplateContext ctx = new_context(); + context_set(&ctx, "domain", global_config.domain); + char *rendered = render_template("opensearch.xml", &ctx); + serve_data(rendered, strlen(rendered), "application/opensearchdescription+xml"); + + free(rendered); + free_context(&ctx); return 0; } @@ -35,6 +43,7 @@ int main() { Config cfg = {.host = DEFAULT_HOST, .port = DEFAULT_PORT, + .domain = "", .proxy = "", .proxy_list_file = "", .max_proxy_retries = DEFAULT_MAX_PROXY_RETRIES, @@ -48,6 +57,8 @@ int main() { fprintf(stderr, "[WARN] Could not load config file, using defaults\n"); } + global_config = cfg; + if (cache_init(cfg.cache_dir) != 0) { fprintf(stderr, "[WARN] Failed to initialize cache, continuing without caching\n"); |
