@@ -7,7 +7,8 @@ use clap::{Arg, ArgAction, Command};
77use std:: sync:: LazyLock ;
88
99use futures_lite:: FutureExt ;
10- use hyper:: { header:: HeaderValue , Body , Request , Response } ;
10+ use hyper:: { header:: HeaderValue , Request , Response } ;
11+ use redlib:: server:: { full, Body } ;
1112use log:: { info, warn} ;
1213use redlib:: client:: { canonical_path, proxy, rate_limit_check, MEDIA_CLIENT } ;
1314use redlib:: server:: { self , RequestExt } ;
@@ -24,7 +25,7 @@ async fn pwa_logo() -> Result<Response<Body>, String> {
2425 Response :: builder ( )
2526 . status ( 200 )
2627 . header ( "content-type" , "image/png" )
27- . body ( include_bytes ! ( "../static/logo.png" ) . as_ref ( ) . into ( ) )
28+ . body ( full ( include_bytes ! ( "../static/logo.png" ) . as_ref ( ) ) )
2829 . unwrap_or_default ( ) ,
2930 )
3031}
@@ -35,7 +36,7 @@ async fn iphone_logo() -> Result<Response<Body>, String> {
3536 Response :: builder ( )
3637 . status ( 200 )
3738 . header ( "content-type" , "image/png" )
38- . body ( include_bytes ! ( "../static/apple-touch-icon.png" ) . as_ref ( ) . into ( ) )
39+ . body ( full ( include_bytes ! ( "../static/apple-touch-icon.png" ) . as_ref ( ) ) )
3940 . unwrap_or_default ( ) ,
4041 )
4142}
@@ -46,7 +47,7 @@ async fn favicon() -> Result<Response<Body>, String> {
4647 . status ( 200 )
4748 . header ( "content-type" , "image/vnd.microsoft.icon" )
4849 . header ( "Cache-Control" , "public, max-age=1209600, s-maxage=86400" )
49- . body ( include_bytes ! ( "../static/favicon.ico" ) . as_ref ( ) . into ( ) )
50+ . body ( full ( include_bytes ! ( "../static/favicon.ico" ) . as_ref ( ) ) )
5051 . unwrap_or_default ( ) ,
5152 )
5253}
@@ -57,7 +58,7 @@ async fn font() -> Result<Response<Body>, String> {
5758 . status ( 200 )
5859 . header ( "content-type" , "font/woff2" )
5960 . header ( "Cache-Control" , "public, max-age=1209600, s-maxage=86400" )
60- . body ( include_bytes ! ( "../static/Inter.var.woff2" ) . as_ref ( ) . into ( ) )
61+ . body ( full ( include_bytes ! ( "../static/Inter.var.woff2" ) . as_ref ( ) ) )
6162 . unwrap_or_default ( ) ,
6263 )
6364}
@@ -68,7 +69,7 @@ async fn opensearch() -> Result<Response<Body>, String> {
6869 . status ( 200 )
6970 . header ( "content-type" , "application/opensearchdescription+xml" )
7071 . header ( "Cache-Control" , "public, max-age=1209600, s-maxage=86400" )
71- . body ( include_bytes ! ( "../static/opensearch.xml" ) . as_ref ( ) . into ( ) )
72+ . body ( full ( include_bytes ! ( "../static/opensearch.xml" ) . as_ref ( ) ) )
7273 . unwrap_or_default ( ) ,
7374 )
7475}
@@ -77,7 +78,7 @@ async fn resource(body: &str, content_type: &str, cache: bool) -> Result<Respons
7778 let mut res = Response :: builder ( )
7879 . status ( 200 )
7980 . header ( "content-type" , content_type)
80- . body ( body. to_string ( ) . into ( ) )
81+ . body ( full ( body. to_string ( ) ) )
8182 . unwrap_or_default ( ) ;
8283
8384 if cache {
@@ -105,7 +106,7 @@ async fn style() -> Result<Response<Body>, String> {
105106 . status ( 200 )
106107 . header ( "content-type" , "text/css" )
107108 . header ( "Cache-Control" , "public, max-age=1209600, s-maxage=86400" )
108- . body ( Body :: from ( STYLE_CSS . clone ( ) ) )
109+ . body ( full ( STYLE_CSS . clone ( ) ) )
109110 . unwrap_or_default ( ) ,
110111 )
111112}
@@ -428,7 +429,7 @@ pub async fn proxy_commit_info() -> Result<Response<Body>, String> {
428429 Response :: builder ( )
429430 . status ( 200 )
430431 . header ( "content-type" , "application/atom+xml" )
431- . body ( Body :: from ( fetch_commit_info ( ) . await ) )
432+ . body ( full ( fetch_commit_info ( ) . await ) )
432433 . unwrap_or_default ( ) ,
433434 )
434435}
@@ -452,7 +453,7 @@ pub async fn proxy_instances() -> Result<Response<Body>, String> {
452453 Response :: builder ( )
453454 . status ( 200 )
454455 . header ( "content-type" , "application/json" )
455- . body ( Body :: from ( fetch_instances ( ) . await ) )
456+ . body ( full ( fetch_instances ( ) . await ) )
456457 . unwrap_or_default ( ) ,
457458 )
458459}
0 commit comments