Add config option to set the HTTP redirect code for external icons

The default code is 307 (temporary) to make it easier to test different icon
services, but once a service has been decided on, users should ideally switch
to using permanent redirects for cacheability.
This commit is contained in:
Jeremy Lin
2021-12-29 18:01:32 -08:00
parent 920371929b
commit b7eedbcddc
3 changed files with 28 additions and 3 deletions

View File

@@ -71,7 +71,14 @@ fn icon_redirect(domain: &str, template: &str) -> Option<Redirect> {
}
let url = template.replace("{}", domain);
Some(Redirect::temporary(url))
match CONFIG.icon_redirect_code() {
308 => Some(Redirect::permanent(url)),
307 => Some(Redirect::temporary(url)),
_ => {
error!("Unexpected redirect code {}", CONFIG.icon_redirect_code());
None
}
}
}
#[get("/<domain>/icon.png")]