de-global services() from api

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-16 08:05:25 +00:00
parent 463f1a1287
commit 8b6018d77d
61 changed files with 1485 additions and 1320 deletions

View file

@ -2,11 +2,10 @@ use std::str;
use axum::{extract::Path, RequestExt, RequestPartsExt};
use bytes::Bytes;
use conduit::err;
use conduit::{err, Result};
use http::request::Parts;
use serde::Deserialize;
use crate::{services, Result};
use service::Services;
#[derive(Deserialize)]
pub(super) struct QueryParams {
@ -21,7 +20,7 @@ pub(super) struct Request {
pub(super) parts: Parts,
}
pub(super) async fn from(request: hyper::Request<axum::body::Body>) -> Result<Request> {
pub(super) async fn from(services: &Services, request: hyper::Request<axum::body::Body>) -> Result<Request> {
let limited = request.with_limited_body();
let (mut parts, body) = limited.into_parts();
@ -30,7 +29,7 @@ pub(super) async fn from(request: hyper::Request<axum::body::Body>) -> Result<Re
let query =
serde_html_form::from_str(query).map_err(|e| err!(Request(Unknown("Failed to read query parameters: {e}"))))?;
let max_body_size = services().globals.config.max_request_size;
let max_body_size = services.globals.config.max_request_size;
let body = axum::body::to_bytes(body, max_body_size)
.await