From da91fcb27129e9261f9ac445510672d3c63716d6 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sun, 17 Nov 2024 15:09:50 +1300 Subject: [PATCH] Pass the request (not a reference) into blossom so it can pull the body --- src/web/blossom/mod.rs | 22 +++++++++++----------- src/web/mod.rs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/web/blossom/mod.rs b/src/web/blossom/mod.rs index d9249e1..8f3a6b6 100644 --- a/src/web/blossom/mod.rs +++ b/src/web/blossom/mod.rs @@ -16,7 +16,7 @@ use hyper::{Request, Response}; mod auth; use auth::{verify_auth, AuthVerb}; -pub async fn handle(request: &Request) -> Result>, Error> { +pub async fn handle(request: Request) -> Result>, Error> { match route(request).await { Ok(response) => Ok(response), Err(e) => match e.inner { @@ -26,7 +26,7 @@ pub async fn handle(request: &Request) -> Result) -> Result>, Error> { +pub async fn route(request: Request) -> Result>, Error> { let p = request.uri().path(); if p.starts_with("/") && p.len() >= 1 + 64 @@ -72,7 +72,7 @@ fn error_response(e: Error) -> Result>, Error> { } fn options_response( - request: &Request, + request: Request, methods: &str, ) -> Result>, Error> { if request @@ -101,7 +101,7 @@ fn options_response( } pub async fn handle_hash( - request: &Request, + request: Request, ) -> Result>, Error> { if matches!(request.method(), &Method::OPTIONS) { return options_response(request, "OPTIONS, HEAD, GET, DELETE"); @@ -132,7 +132,7 @@ pub async fn handle_hash( .body(body)?) } &Method::DELETE => { - let auth_data = verify_auth(request)?; + let auth_data = verify_auth(&request)?; if auth_data.verb != Some(AuthVerb::Delete) { return Err(ChorusError::BlossomAuthFailure( "Delete was not authorized".to_string(), @@ -156,37 +156,37 @@ pub async fn handle_hash( } pub async fn handle_upload( - request: &Request, + request: Request, ) -> Result>, Error> { if matches!(request.method(), &Method::OPTIONS) { return options_response(request, "OPTIONS, HEAD, PUT"); } - let _auth_data = verify_auth(request)?; + let _auth_data = verify_auth(&request)?; unimplemented!() } pub async fn handle_list( - request: &Request, + request: Request, ) -> Result>, Error> { if matches!(request.method(), &Method::OPTIONS) { return options_response(request, "OPTIONS, GET"); } - let _auth_data = verify_auth(request)?; + let _auth_data = verify_auth(&request)?; unimplemented!() } pub async fn handle_mirror( - request: &Request, + request: Request, ) -> Result>, Error> { if matches!(request.method(), &Method::OPTIONS) { return options_response(request, "OPTIONS, PUT"); } - let _auth_data = verify_auth(request)?; + let _auth_data = verify_auth(&request)?; unimplemented!() } diff --git a/src/web/mod.rs b/src/web/mod.rs index 23c5775..8dd3490 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -47,7 +47,7 @@ pub async fn serve_http( // Try blossom if enabled if GLOBALS.config.read().blossom_directory.is_some() { - match blossom::handle(&request).await { + match blossom::handle(request).await { Ok(response) => return Ok(response), Err(e) => { if !matches!(e.inner, ChorusError::SignalNotBlossom) {