Implement nonfunctional COPY and MOVE method

Fixes #69 for now
This commit is contained in:
Lennart
2025-06-10 17:42:03 +02:00
parent 103ac0b1f9
commit 32225bdda8
7 changed files with 112 additions and 28 deletions

View File

@@ -1,9 +1,19 @@
use axum::{body::Body, extract::FromRequestParts, response::IntoResponse};
use thiserror::Error;
#[derive(Error, Debug)]
#[error("Invalid Overwrite header")]
pub struct InvalidOverwriteHeader;
impl IntoResponse for InvalidOverwriteHeader {
fn into_response(self) -> axum::response::Response {
axum::response::Response::builder()
.status(axum::http::StatusCode::BAD_REQUEST)
.body(Body::new("Invalid Overwrite header".to_string()))
.expect("this always works")
}
}
#[derive(Debug, PartialEq, Default)]
pub enum Overwrite {
#[default]
@@ -17,6 +27,21 @@ impl Overwrite {
}
}
impl<S: Send + Sync> FromRequestParts<S> for Overwrite {
type Rejection = InvalidOverwriteHeader;
async fn from_request_parts(
parts: &mut axum::http::request::Parts,
_state: &S,
) -> Result<Self, Self::Rejection> {
if let Some(overwrite_header) = parts.headers.get("Overwrite") {
overwrite_header.as_bytes().try_into()
} else {
Ok(Self::default())
}
}
}
impl TryFrom<&[u8]> for Overwrite {
type Error = InvalidOverwriteHeader;