Use from_static instead of from_string

This commit is contained in:
Tokarak 2025-03-18 02:32:13 +00:00
parent 3d85df5044
commit 38422a83b0

View file

@ -5,7 +5,7 @@
use cached::proc_macro::cached;
use clap::{Arg, ArgAction, Command};
use std::str::FromStr;
use bincode::Error;
use futures_lite::FutureExt;
use hyper::Uri;
use hyper::{header::HeaderValue, Body, Request, Response};
@ -83,9 +83,7 @@ async fn resource(body: &str, content_type: &str, cache: bool) -> Result<Respons
.unwrap_or_default();
if cache {
if let Ok(val) = HeaderValue::from_str("public, max-age=1209600, s-maxage=86400") {
res.headers_mut().insert("Cache-Control", val);
}
res.headers_mut().insert("Cache-Control", HeaderValue::from_static("public, max-age=1209600, s-maxage=86400"));
}
Ok(res)
@ -433,7 +431,7 @@ pub async fn proxy_commit_info() -> Result<Response<Body>, String> {
#[cached(time = 600)]
async fn fetch_commit_info() -> String {
let uri = Uri::from_str("https://github.com/redlib-org/redlib/commits/main.atom").expect("Invalid URI");
let uri = Uri::from_static("https://github.com/redlib-org/redlib/commits/main.atom");
let resp: Body = CLIENT.get(uri).await.expect("Failed to request GitHub").into_body();
@ -452,7 +450,7 @@ pub async fn proxy_instances() -> Result<Response<Body>, String> {
#[cached(time = 600)]
async fn fetch_instances() -> String {
let uri = Uri::from_str("https://raw.githubusercontent.com/redlib-org/redlib-instances/refs/heads/main/instances.json").expect("Invalid URI");
let uri = Uri::from_static("https://raw.githubusercontent.com/redlib-org/redlib-instances/refs/heads/main/instances.json");
let resp: Body = CLIENT.get(uri).await.expect("Failed to request GitHub").into_body();