Commit

Author:

Hash:

Timestamp:

+201 -137 +/-12 browse

Kevin Schoon [me@kevinschoon.com]

aeefffa7431fbb3686b58aef7c0096150d92204b

Wed, 10 Jan 2024 15:17:16 +0000 (1.5 years ago)

upgrade axum to the latest version
1diff --git a/Cargo.lock b/Cargo.lock
2index 105786c..b7886d6 100644
3--- a/Cargo.lock
4+++ b/Cargo.lock
5 @@ -414,20 +414,20 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
6
7 [[package]]
8 name = "axum"
9- version = "0.6.20"
10+ version = "0.7.3"
11 source = "registry+https://github.com/rust-lang/crates.io-index"
12- checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
13+ checksum = "d09dbe0e490df5da9d69b36dca48a76635288a82f92eca90024883a56202026d"
14 dependencies = [
15 "async-trait",
16 "axum-core",
17 "axum-macros",
18- "bitflags 1.3.2",
19 "bytes",
20 "futures-util",
21- "headers",
22- "http",
23- "http-body",
24- "hyper",
25+ "http 1.0.0",
26+ "http-body 1.0.0",
27+ "http-body-util",
28+ "hyper 1.1.0",
29+ "hyper-util",
30 "itoa",
31 "matchit",
32 "memchr",
33 @@ -444,42 +444,47 @@ dependencies = [
34 "tower",
35 "tower-layer",
36 "tower-service",
37+ "tracing",
38 ]
39
40 [[package]]
41 name = "axum-core"
42- version = "0.3.4"
43+ version = "0.4.2"
44 source = "registry+https://github.com/rust-lang/crates.io-index"
45- checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
46+ checksum = "e87c8503f93e6d144ee5690907ba22db7ba79ab001a932ab99034f0fe836b3df"
47 dependencies = [
48 "async-trait",
49 "bytes",
50 "futures-util",
51- "http",
52- "http-body",
53+ "http 1.0.0",
54+ "http-body 1.0.0",
55+ "http-body-util",
56 "mime",
57+ "pin-project-lite",
58 "rustversion",
59+ "sync_wrapper",
60 "tower-layer",
61 "tower-service",
62+ "tracing",
63 ]
64
65 [[package]]
66 name = "axum-extra"
67- version = "0.8.0"
68+ version = "0.9.1"
69 source = "registry+https://github.com/rust-lang/crates.io-index"
70- checksum = "4ab90e7b70bea63a153137162affb6a0bce26b584c24a4c7885509783e2cf30b"
71+ checksum = "881348a37b079994894b6e5e46edcc4b8a60e1c0333669a65b810abeed780598"
72 dependencies = [
73 "axum",
74 "axum-core",
75 "bytes",
76 "cookie",
77 "futures-util",
78- "http",
79- "http-body",
80+ "http 1.0.0",
81+ "http-body 1.0.0",
82+ "http-body-util",
83 "mime",
84 "pin-project-lite",
85 "serde",
86- "tokio",
87 "tower",
88 "tower-layer",
89 "tower-service",
90 @@ -487,9 +492,9 @@ dependencies = [
91
92 [[package]]
93 name = "axum-macros"
94- version = "0.3.8"
95+ version = "0.4.0"
96 source = "registry+https://github.com/rust-lang/crates.io-index"
97- checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62"
98+ checksum = "5a2edad600410b905404c594e2523549f1bcd4bded1e252c8f74524ccce0b867"
99 dependencies = [
100 "heck",
101 "proc-macro2",
102 @@ -1088,9 +1093,9 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f"
103
104 [[package]]
105 name = "cookie"
106- version = "0.17.0"
107+ version = "0.18.0"
108 source = "registry+https://github.com/rust-lang/crates.io-index"
109- checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24"
110+ checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8"
111 dependencies = [
112 "percent-encoding",
113 "time 0.3.30",
114 @@ -2144,7 +2149,7 @@ dependencies = [
115 "futures-core",
116 "futures-sink",
117 "futures-util",
118- "http",
119+ "http 0.2.9",
120 "indexmap 1.9.3",
121 "slab",
122 "tokio",
123 @@ -2153,6 +2158,25 @@ dependencies = [
124 ]
125
126 [[package]]
127+ name = "h2"
128+ version = "0.4.1"
129+ source = "registry+https://github.com/rust-lang/crates.io-index"
130+ checksum = "991910e35c615d8cab86b5ab04be67e6ad24d2bf5f4f11fdbbed26da999bbeab"
131+ dependencies = [
132+ "bytes",
133+ "fnv",
134+ "futures-core",
135+ "futures-sink",
136+ "futures-util",
137+ "http 1.0.0",
138+ "indexmap 2.0.0",
139+ "slab",
140+ "tokio",
141+ "tokio-util",
142+ "tracing",
143+ ]
144+
145+ [[package]]
146 name = "hashbrown"
147 version = "0.12.3"
148 source = "registry+https://github.com/rust-lang/crates.io-index"
149 @@ -2178,30 +2202,6 @@ dependencies = [
150 ]
151
152 [[package]]
153- name = "headers"
154- version = "0.3.9"
155- source = "registry+https://github.com/rust-lang/crates.io-index"
156- checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
157- dependencies = [
158- "base64 0.21.3",
159- "bytes",
160- "headers-core",
161- "http",
162- "httpdate",
163- "mime",
164- "sha1",
165- ]
166-
167- [[package]]
168- name = "headers-core"
169- version = "0.2.0"
170- source = "registry+https://github.com/rust-lang/crates.io-index"
171- checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
172- dependencies = [
173- "http",
174- ]
175-
176- [[package]]
177 name = "heck"
178 version = "0.4.1"
179 source = "registry+https://github.com/rust-lang/crates.io-index"
180 @@ -2281,13 +2281,47 @@ dependencies = [
181 ]
182
183 [[package]]
184+ name = "http"
185+ version = "1.0.0"
186+ source = "registry+https://github.com/rust-lang/crates.io-index"
187+ checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea"
188+ dependencies = [
189+ "bytes",
190+ "fnv",
191+ "itoa",
192+ ]
193+
194+ [[package]]
195 name = "http-body"
196 version = "0.4.5"
197 source = "registry+https://github.com/rust-lang/crates.io-index"
198 checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
199 dependencies = [
200 "bytes",
201- "http",
202+ "http 0.2.9",
203+ "pin-project-lite",
204+ ]
205+
206+ [[package]]
207+ name = "http-body"
208+ version = "1.0.0"
209+ source = "registry+https://github.com/rust-lang/crates.io-index"
210+ checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
211+ dependencies = [
212+ "bytes",
213+ "http 1.0.0",
214+ ]
215+
216+ [[package]]
217+ name = "http-body-util"
218+ version = "0.1.0"
219+ source = "registry+https://github.com/rust-lang/crates.io-index"
220+ checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840"
221+ dependencies = [
222+ "bytes",
223+ "futures-util",
224+ "http 1.0.0",
225+ "http-body 1.0.0",
226 "pin-project-lite",
227 ]
228
229 @@ -2334,9 +2368,9 @@ dependencies = [
230 "futures-channel",
231 "futures-core",
232 "futures-util",
233- "h2",
234- "http",
235- "http-body",
236+ "h2 0.3.21",
237+ "http 0.2.9",
238+ "http-body 0.4.5",
239 "httparse",
240 "httpdate",
241 "itoa",
242 @@ -2349,19 +2383,56 @@ dependencies = [
243 ]
244
245 [[package]]
246+ name = "hyper"
247+ version = "1.1.0"
248+ source = "registry+https://github.com/rust-lang/crates.io-index"
249+ checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75"
250+ dependencies = [
251+ "bytes",
252+ "futures-channel",
253+ "futures-util",
254+ "h2 0.4.1",
255+ "http 1.0.0",
256+ "http-body 1.0.0",
257+ "httparse",
258+ "httpdate",
259+ "itoa",
260+ "pin-project-lite",
261+ "tokio",
262+ ]
263+
264+ [[package]]
265 name = "hyper-tls"
266 version = "0.5.0"
267 source = "registry+https://github.com/rust-lang/crates.io-index"
268 checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
269 dependencies = [
270 "bytes",
271- "hyper",
272+ "hyper 0.14.27",
273 "native-tls",
274 "tokio",
275 "tokio-native-tls",
276 ]
277
278 [[package]]
279+ name = "hyper-util"
280+ version = "0.1.2"
281+ source = "registry+https://github.com/rust-lang/crates.io-index"
282+ checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67"
283+ dependencies = [
284+ "bytes",
285+ "futures-channel",
286+ "futures-util",
287+ "http 1.0.0",
288+ "http-body 1.0.0",
289+ "hyper 1.1.0",
290+ "pin-project-lite",
291+ "socket2 0.5.5",
292+ "tokio",
293+ "tracing",
294+ ]
295+
296+ [[package]]
297 name = "iana-time-zone"
298 version = "0.1.57"
299 source = "registry+https://github.com/rust-lang/crates.io-index"
300 @@ -4160,10 +4231,10 @@ dependencies = [
301 "encoding_rs",
302 "futures-core",
303 "futures-util",
304- "h2",
305- "http",
306- "http-body",
307- "hyper",
308+ "h2 0.3.21",
309+ "http 0.2.9",
310+ "http-body 0.4.5",
311+ "hyper 0.14.27",
312 "hyper-tls",
313 "ipnet",
314 "js-sys",
315 @@ -5511,8 +5582,8 @@ dependencies = [
316 "bytes",
317 "futures-core",
318 "futures-util",
319- "http",
320- "http-body",
321+ "http 0.2.9",
322+ "http-body 0.4.5",
323 "http-range-header",
324 "pin-project-lite",
325 "tower-layer",
326 diff --git a/Cargo.toml b/Cargo.toml
327index 301a4a1..9670b23 100644
328--- a/Cargo.toml
329+++ b/Cargo.toml
330 @@ -69,10 +69,10 @@ rss = "2.0.5"
331 globwalk = "0.8.1"
332 anyhow = "1.0.75"
333 tokio = { version = "1.32.0", features = ["full"] }
334- axum = { version = "0.6.20", features = ["macros", "headers"] }
335- axum-extra = { version = "0.8.0", features = ["cookie"] }
336+ axum = { version = "0.7.3", features = ["macros"] }
337+ axum-extra = { version = "0.9.1", features = ["cookie"] }
338 tokio-util = { version = "0.7.9", features = ["io", "compat"] }
339- tower-http = { version = "0.4.4", features = ["tracing", "add-extension", "trace"] }
340+ tower-http = { version = "0.4.4", features = ["tracing", "add-extension", "trace", "normalize-path"] }
341 tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
342 tracing = "0.1.37"
343 tower = { version = "0.4.13", features = ["util", "timeout", "tracing"] }
344 diff --git a/src/web2/error.rs b/src/web2/error.rs
345index fc2d786..fce97c3 100644
346--- a/src/web2/error.rs
347+++ b/src/web2/error.rs
348 @@ -2,7 +2,7 @@ use std::error::Error as StdError;
349 use std::fmt::Display;
350 use std::io::Error as IoError;
351
352- use axum::{body::boxed, body::Empty, response::IntoResponse, response::Response};
353+ use axum::{body::Body, response::IntoResponse, response::Response};
354 use tera::Error as TeraError;
355
356 use ayllu_database::Error as SqlError;
357 @@ -21,10 +21,10 @@ pub enum Error {
358 }
359
360 impl IntoResponse for Error {
361+ // TODO: this makes absolutely no sense
362 fn into_response(self) -> Response {
363 Response::builder()
364- .extension(self)
365- .body(boxed(Empty::new()))
366+ .body(Body::empty())
367 .unwrap()
368 }
369 }
370 diff --git a/src/web2/middleware/error.rs b/src/web2/middleware/error.rs
371index 905cc68..12dbfa6 100644
372--- a/src/web2/middleware/error.rs
373+++ b/src/web2/middleware/error.rs
374 @@ -2,13 +2,11 @@ use std::io::ErrorKind as IoErrorKind;
375 use std::sync::Arc;
376
377 use axum::{
378- body::boxed,
379- extract::State,
380- http::{header::CONTENT_TYPE, Request, StatusCode},
381+ extract::{Request, State},
382+ http::StatusCode,
383 middleware::Next,
384- response::Response,
385+ response::{Html, IntoResponse, Response},
386 };
387- use mime::TEXT_HTML_UTF_8;
388 use tera::Tera;
389
390 use crate::config::Config;
391 @@ -16,11 +14,11 @@ use crate::web2::error::Error;
392 use crate::web2::extractors::config::ConfigReader;
393 use crate::web2::terautil::{Loader, Options};
394
395- pub async fn middleware<B>(
396+ pub async fn middleware(
397 State(state): State<Arc<(Config, Vec<(String, Tera)>)>>,
398 ConfigReader(client_config): ConfigReader,
399- req: Request<B>,
400- next: Next<B>,
401+ req: Request,
402+ next: Next,
403 ) -> Response {
404 let response = next.run(req).await;
405 if let Some(error) = response.extensions().get::<Error>() {
406 @@ -63,12 +61,7 @@ pub async fn middleware<B>(
407 log::error!("Error: {}", error.to_string());
408 template.render("5xx.html", &ctx).unwrap()
409 };
410-
411- return Response::builder()
412- .header(CONTENT_TYPE, TEXT_HTML_UTF_8.as_ref())
413- .status(status_code)
414- .body(boxed(template_str))
415- .unwrap();
416+ return Html::from(template_str).into_response();
417 }
418 response
419 }
420 diff --git a/src/web2/middleware/repository.rs b/src/web2/middleware/repository.rs
421index e4d2aae..17378a9 100644
422--- a/src/web2/middleware/repository.rs
423+++ b/src/web2/middleware/repository.rs
424 @@ -2,8 +2,7 @@ use std::path::PathBuf;
425 use std::time::SystemTime;
426
427 use axum::{
428- extract::{Path, State},
429- http::Request,
430+ extract::{Path, State, Request},
431 middleware::Next,
432 response::{IntoResponse, Response},
433 };
434 @@ -108,7 +107,7 @@ impl Preamble {
435 }
436 }
437
438- pub async fn middleware<B>(
439+ pub async fn middleware(
440 State(config): State<Config>,
441 Path(CommonParams {
442 collection,
443 @@ -116,8 +115,8 @@ pub async fn middleware<B>(
444 commitish,
445 file_path,
446 }): Path<CommonParams>,
447- mut req: Request<B>,
448- next: Next<B>,
449+ mut req: Request,
450+ next: Next,
451 ) -> Response {
452 let preamble = Preamble::new(&config, collection, name, commitish, file_path);
453 match preamble {
454 diff --git a/src/web2/middleware/rpc_initiator.rs b/src/web2/middleware/rpc_initiator.rs
455index a1014bc..78d2642 100644
456--- a/src/web2/middleware/rpc_initiator.rs
457+++ b/src/web2/middleware/rpc_initiator.rs
458 @@ -2,9 +2,9 @@ use std::sync::Arc;
459
460 use crate::web2::terautil::{Loader, Options};
461 use axum::{
462- body::boxed,
463- extract::State,
464- http::{header::CONTENT_TYPE, Request, StatusCode},
465+ body::Body,
466+ extract::{Request, State},
467+ http::{header::CONTENT_TYPE, StatusCode},
468 middleware::Next,
469 response::Response,
470 };
471 @@ -66,30 +66,32 @@ fn plugin_not_enabled(
472 Response::builder()
473 .header(CONTENT_TYPE, TEXT_HTML_UTF_8.as_ref())
474 .status(StatusCode::NOT_IMPLEMENTED)
475- .body(boxed(template_str))
476+ .body(Body::new(template_str))
477 .unwrap()
478 }
479
480 /// configure an optinoal plugin for use in a handler
481- pub async fn optional<B>(
482- State(cfg): State<Arc<Config>>,
483- mut req: Request<B>,
484- next: Next<B>,
485- ) -> Response {
486+ pub async fn optional(State(cfg): State<Arc<Config>>, mut req: Request, next: Next) -> Response {
487 req.extensions_mut().insert(Initiator {
488- mail: cfg.mail.as_ref().map(|mail_cfg| Client::new(&mail_cfg.socket_path)),
489- xmpp: cfg.xmpp.as_ref().map(|xmpp_cfg| Client::new(&xmpp_cfg.socket_path)),
490+ mail: cfg
491+ .mail
492+ .as_ref()
493+ .map(|mail_cfg| Client::new(&mail_cfg.socket_path)),
494+ xmpp: cfg
495+ .xmpp
496+ .as_ref()
497+ .map(|xmpp_cfg| Client::new(&xmpp_cfg.socket_path)),
498 });
499 next.run(req).await
500 }
501
502 /// configure a required plugin for use in a handler, if it is not configured
503 /// an error page will be returned from the handler
504- pub async fn required<B>(
505+ pub async fn required(
506 State(state): State<Arc<(Config, Vec<(String, Tera)>, &'static [Kind])>>,
507 ConfigReader(client_config): ConfigReader,
508- mut req: Request<B>,
509- next: Next<B>,
510+ mut req: Request,
511+ next: Next,
512 ) -> Response {
513 let mut initiator = Initiator::default();
514 for kind in state.2.iter() {
515 diff --git a/src/web2/middleware/sites.rs b/src/web2/middleware/sites.rs
516index 2be07d5..eecd85b 100644
517--- a/src/web2/middleware/sites.rs
518+++ b/src/web2/middleware/sites.rs
519 @@ -2,9 +2,9 @@ use std::fs::read_dir;
520 use std::path::{Path, PathBuf};
521
522 use axum::{
523- body,
524- extract::State,
525- http::{header, Request, StatusCode},
526+ body::Body,
527+ extract::{Request, State},
528+ http::{header, StatusCode},
529 middleware::Next,
530 response::{IntoResponse, Response},
531 };
532 @@ -52,10 +52,10 @@ pub fn sites(cfg: Config) -> Result<Vec<(String, (String, String))>, Error> {
533 Ok(sites)
534 }
535
536- pub async fn middleware<B>(
537+ pub async fn middleware(
538 State((cfg, sites)): State<(Config, Vec<(String, (String, String))>)>,
539- req: Request<B>,
540- next: Next<B>,
541+ req: Request,
542+ next: Next,
543 ) -> Result<Response, Error> {
544 if !cfg.sites.enabled {
545 return Ok(next.run(req).await);
546 @@ -122,7 +122,7 @@ pub async fn middleware<B>(
547 let mime_type = from_path(path.to_str().unwrap()).first_or_octet_stream();
548 let response = Response::builder()
549 .header(header::CONTENT_TYPE, mime_type.to_string())
550- .body(body::boxed(body::Body::from(blob.content)))
551+ .body(Body::from(blob.content))
552 .unwrap();
553 return Ok(response);
554 };
555 diff --git a/src/web2/middleware/template.rs b/src/web2/middleware/template.rs
556index 6ded38b..e93c093 100644
557--- a/src/web2/middleware/template.rs
558+++ b/src/web2/middleware/template.rs
559 @@ -3,8 +3,8 @@ use std::sync::Arc;
560 use tera::{Context as TeraContext, Tera};
561
562 use axum::{
563+ extract::Request,
564 extract::{Path, State},
565- http::Request,
566 middleware::Next,
567 response::Response,
568 };
569 @@ -21,12 +21,12 @@ pub struct CommonParams {
570 pub name: Option<String>,
571 }
572
573- pub async fn middleware<B>(
574+ pub async fn middleware(
575 State(state): State<Arc<(Config, Vec<(String, Tera)>)>>,
576 ConfigReader(config): ConfigReader,
577 Path(CommonParams { collection, name }): Path<CommonParams>,
578- mut req: Request<B>,
579- next: Next<B>,
580+ mut req: Request,
581+ next: Next,
582 ) -> Response {
583 let loader = Loader {
584 templates: state.1.clone(),
585 diff --git a/src/web2/routes/assets.rs b/src/web2/routes/assets.rs
586index 0cf32f9..976f19b 100644
587--- a/src/web2/routes/assets.rs
588+++ b/src/web2/routes/assets.rs
589 @@ -1,6 +1,6 @@
590 use std::path::PathBuf;
591
592- use axum::{body, extract::Path, http::header, response::Response, Extension};
593+ use axum::{body::Body, extract::Path, http::header, response::Response, Extension};
594
595 use tokio::fs::File;
596 use tokio_util::io::ReaderStream;
597 @@ -22,10 +22,9 @@ pub async fn serve_css(
598 file_path.push("main.min.css");
599 let file = tokio::fs::File::open(file_path).await?;
600 let stream = ReaderStream::new(file);
601- let body = body::StreamBody::new(stream);
602 Ok(Response::builder()
603 .header(header::CONTENT_TYPE, mime::TEXT_CSS.as_ref())
604- .body(body::boxed(body))
605+ .body(Body::from_stream(stream))
606 .unwrap())
607 }
608
609 @@ -59,12 +58,11 @@ pub async fn serve_asset(
610 }
611 };
612 let stream = ReaderStream::new(file);
613- let body = body::StreamBody::new(stream);
614 let mime = mime_guess::from_path(file_path)
615 .first_or_octet_stream()
616 .to_string();
617 Ok(Response::builder()
618 .header("Content-Type", mime)
619- .body(body::boxed(body))
620+ .body(Body::from_stream(stream))
621 .unwrap())
622 }
623 diff --git a/src/web2/routes/refs.rs b/src/web2/routes/refs.rs
624index 33fbfe4..1996b25 100644
625--- a/src/web2/routes/refs.rs
626+++ b/src/web2/routes/refs.rs
627 @@ -1,11 +1,11 @@
628 use serde::Serialize;
629
630 use axum::{
631- body::StreamBody,
632+ body::Body,
633 extract::{Extension, Path},
634- response::{Html, IntoResponse, Response},
635+ http::header::CONTENT_TYPE,
636+ response::{Html, Response},
637 };
638-
639 use tokio_util::io::ReaderStream;
640
641 use crate::web2::error::Error;
642 @@ -87,6 +87,9 @@ pub async fn archive(
643 let ref_name = ref_name.trim_end_matches(".tar.gz");
644 let mut child_proc = repository.archive(ref_name)?;
645 let stdout = child_proc.stdout.take().unwrap();
646- let x = ReaderStream::new(stdout);
647- Ok(StreamBody::new(x).into_response())
648+ let response = Response::builder()
649+ .header(CONTENT_TYPE, "application/gzip")
650+ .body(Body::from_stream(ReaderStream::new(stdout)))
651+ .unwrap();
652+ Ok(response)
653 }
654 diff --git a/src/web2/routes/rss.rs b/src/web2/routes/rss.rs
655index 737050e..d2e4dab 100644
656--- a/src/web2/routes/rss.rs
657+++ b/src/web2/routes/rss.rs
658 @@ -1,7 +1,7 @@
659 use std::path::PathBuf;
660
661 use axum::{
662- body::boxed,
663+ body::Body,
664 extract::{Extension, OriginalUri},
665 http::header::CONTENT_TYPE,
666 response::Response,
667 @@ -294,10 +294,9 @@ pub async fn feed_firehose(
668 builder.scan_repositories(cfg.collections)?,
669 Duration::days(7),
670 )?;
671- let body = boxed(stylesheet_hack(channel.to_string()));
672 let response = Response::builder()
673 .header(CONTENT_TYPE, TEXT_XML.as_ref())
674- .body(body)
675+ .body(Body::new(stylesheet_hack(channel.to_string())))
676 .unwrap();
677 Ok(response)
678 }
679 @@ -316,10 +315,9 @@ pub async fn feed_1d(
680 builder.scan_repositories(cfg.collections)?,
681 Timeframe::DAILY,
682 )?;
683- let body = boxed(stylesheet_hack(channel.to_string()));
684 let response = Response::builder()
685 .header(CONTENT_TYPE, TEXT_XML.as_ref())
686- .body(body)
687+ .body(Body::new(stylesheet_hack(channel.to_string())))
688 .unwrap();
689 Ok(response)
690 }
691 @@ -338,10 +336,9 @@ pub async fn feed_1w(
692 builder.scan_repositories(cfg.collections)?,
693 Timeframe::WEEKLY,
694 )?;
695- let body = boxed(stylesheet_hack(channel.to_string()));
696 let response = Response::builder()
697 .header(CONTENT_TYPE, TEXT_XML.as_ref())
698- .body(body)
699+ .body(Body::new(stylesheet_hack(channel.to_string())))
700 .unwrap();
701 Ok(response)
702 }
703 @@ -360,10 +357,9 @@ pub async fn feed_1m(
704 builder.scan_repositories(cfg.collections)?,
705 Timeframe::MONTHLY,
706 )?;
707- let body = boxed(stylesheet_hack(channel.to_string()));
708 let response = Response::builder()
709 .header(CONTENT_TYPE, TEXT_XML.as_ref())
710- .body(body)
711+ .body(Body::new(stylesheet_hack(channel.to_string())))
712 .unwrap();
713 Ok(response)
714 }
715 @@ -385,10 +381,9 @@ pub async fn feed_repository_firehose(
716 ),
717 };
718 let channel = builder.firehose(vec![(preamble.repo_path, project_url)], Duration::days(7))?;
719- let body = boxed(stylesheet_hack(channel.to_string()));
720 let response = Response::builder()
721 .header(CONTENT_TYPE, TEXT_XML.as_ref())
722- .body(body)
723+ .body(Body::new(stylesheet_hack(channel.to_string())))
724 .unwrap();
725 Ok(response)
726 }
727 @@ -410,10 +405,9 @@ pub async fn feed_repository_1d(
728 ),
729 };
730 let channel = builder.summary(vec![(preamble.repo_path, project_url)], Timeframe::DAILY)?;
731- let body = boxed(stylesheet_hack(channel.to_string()));
732 let response = Response::builder()
733 .header(CONTENT_TYPE, TEXT_XML.as_ref())
734- .body(body)
735+ .body(Body::new(stylesheet_hack(channel.to_string())))
736 .unwrap();
737 Ok(response)
738 }
739 @@ -435,10 +429,9 @@ pub async fn feed_repository_1w(
740 ),
741 };
742 let channel = builder.summary(vec![(preamble.repo_path, project_url)], Timeframe::WEEKLY)?;
743- let body = boxed(stylesheet_hack(channel.to_string()));
744 let response = Response::builder()
745 .header(CONTENT_TYPE, TEXT_XML.as_ref())
746- .body(body)
747+ .body(Body::new(stylesheet_hack(channel.to_string())))
748 .unwrap();
749 Ok(response)
750 }
751 @@ -460,10 +453,9 @@ pub async fn feed_repository_1m(
752 ),
753 };
754 let channel = builder.summary(vec![(preamble.repo_path, project_url)], Timeframe::MONTHLY)?;
755- let body = boxed(stylesheet_hack(channel.to_string()));
756 let response = Response::builder()
757 .header(CONTENT_TYPE, TEXT_XML.as_ref())
758- .body(body)
759+ .body(Body::new(stylesheet_hack(channel.to_string())))
760 .unwrap();
761 Ok(response)
762 }
763 diff --git a/src/web2/server.rs b/src/web2/server.rs
764index 024e2d8..2906991 100644
765--- a/src/web2/server.rs
766+++ b/src/web2/server.rs
767 @@ -4,11 +4,10 @@ use std::fs;
768 use std::net::{SocketAddr, SocketAddrV4};
769 use std::sync::Arc;
770
771- use axum::{
772- body::Body, http::Request, middleware::from_fn_with_state, routing, Extension, Router, Server,
773- };
774+ use axum::{body::Body, http::Request, middleware::from_fn_with_state, routing, Extension, Router};
775 use globwalk::glob_builder;
776 use tera::Tera;
777+ use tokio::net::TcpListener;
778 use tower_http::trace::{DefaultOnResponse, TraceLayer};
779 use tracing::{Level, Span};
780
781 @@ -280,16 +279,23 @@ pub async fn serve(cfg: &Config) -> Result<(), Box<dyn Error>> {
782 (cfg.clone(), site_mapping),
783 sites::middleware,
784 ))
785+ /*
786 .layer(
787 TraceLayer::new_for_http()
788 .on_request(|request: &Request<Body>, _span: &Span| {
789 tracing::info!("started {} {}", request.method(), request.uri().path())
790 })
791 .on_response(DefaultOnResponse::new().level(Level::INFO)),
792- );
793+ )
794+ */
795+ ;
796 log::info!("listening @ {}", cfg.http.address);
797+ let listener = TcpListener::bind(address).await?;
798+ axum::serve(listener, router.into_make_service()).await?;
799+ /*
800 Server::bind(&SocketAddr::V4(address))
801 .serve(router.into_make_service())
802 .await?;
803+ */
804 Ok(())
805 }