Skip to content

Commit

Permalink
ref: Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed Sep 6, 2024
1 parent f0fdc11 commit 30905ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions relay-server/src/endpoints/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::Deserialize;

use crate::endpoints::common::{self, BadStoreRequest};
use crate::envelope::{AttachmentType, Envelope};
use crate::extractors::{RequestMeta, Xt};
use crate::extractors::{Extractor, RequestMeta};
use crate::service::ServiceState;
use crate::utils;

Expand Down Expand Up @@ -35,7 +35,7 @@ pub async fn handle(
state: ServiceState,
meta: RequestMeta,
Path(path): Path<AttachmentPath>,
Xt(multipart): Xt<Multipart<'static>>,
Extractor(multipart): Extractor<Multipart<'static>>,
) -> Result<impl IntoResponse, BadStoreRequest> {
let envelope = extract_envelope(meta, path, multipart).await?;
common::handle_envelope(&state, envelope).await?;
Expand Down
4 changes: 2 additions & 2 deletions relay-server/src/endpoints/minidump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use relay_event_schema::protocol::EventId;
use crate::constants::{ITEM_NAME_BREADCRUMBS1, ITEM_NAME_BREADCRUMBS2, ITEM_NAME_EVENT};
use crate::endpoints::common::{self, BadStoreRequest, TextResponse};
use crate::envelope::{AttachmentType, ContentType, Envelope, Item, ItemType};
use crate::extractors::{RawContentType, RequestMeta, Xt};
use crate::extractors::{Extractor, RawContentType, RequestMeta};
use crate::service::ServiceState;
use crate::utils;

Expand Down Expand Up @@ -137,7 +137,7 @@ async fn handle(
let envelope = if MINIDUMP_RAW_CONTENT_TYPES.contains(&content_type.as_ref()) {
extract_raw_minidump(request.extract().await?, meta)?
} else {
let Xt(multipart) = request.extract_with_state(&state).await?;
let Extractor(multipart) = request.extract_with_state(&state).await?;
extract_multipart(multipart, meta).await?
};

Expand Down
26 changes: 13 additions & 13 deletions relay-server/src/extractors/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use multer::Multipart;
use crate::service::ServiceState;
use crate::utils::{self, ApiErrorResponse};

/// A transparent wrapper around a type that implements [`FromRequest`] or [`IntoResponse`].
/// A transparent wrapper around a remote type that implements [`FromRequest`] or [`IntoResponse`].
///
/// # Example
///
Expand All @@ -18,45 +18,45 @@ use crate::utils::{self, ApiErrorResponse};
/// use axum::extract::{FromRequest, Request};
/// use axum::response::IntoResponse;
///
/// use crate::extractors::Xt;
/// use crate::extractors::Remote;
///
/// // Derive `FromRequest` for `bool` for illustration purposes:
/// #[axum::async_trait]
/// impl<S> axum::extract::FromRequest<S> for Xt<bool> {
/// type Rejection = Xt<Infallible>;
/// impl<S> axum::extract::FromRequest<S> for Remote<bool> {
/// type Rejection = Remote<Infallible>;
///
/// async fn from_request(request: Request) -> Result<Self, Self::Rejection> {
/// Ok(Xt(true))
/// Ok(Remote(true))
/// }
/// }
///
/// impl IntoResponse for Xt<Infallible> {
/// impl IntoResponse for Remote<Infallible> {
/// fn into_response(self) -> axum::response::Response {
/// match self.0 {}
/// }
/// }
/// ```
#[derive(Debug)]
pub struct Xt<T>(pub T);
pub struct Remote<T>(pub T);

impl<T> From<T> for Xt<T> {
impl<T> From<T> for Remote<T> {
fn from(inner: T) -> Self {
Self(inner)
}
}

#[axum::async_trait]
impl FromRequest<ServiceState> for Xt<Multipart<'static>> {
type Rejection = Xt<multer::Error>;
impl FromRequest<ServiceState> for Remote<Multipart<'static>> {
type Rejection = Remote<multer::Error>;

async fn from_request(request: Request, state: &ServiceState) -> Result<Self, Self::Rejection> {
utils::multipart_from_request(request, state.config())
.map(Xt)
.map_err(Xt)
.map(Remote)
.map_err(Remote)
}
}

impl IntoResponse for Xt<multer::Error> {
impl IntoResponse for Remote<multer::Error> {
fn into_response(self) -> Response {
let Self(ref error) = self;

Expand Down

0 comments on commit 30905ea

Please sign in to comment.