pub struct RequestCtx {
pub state: Arc<ServerState>,
pub token: String,
pub site_name: String,
}Expand description
Bundled extractor for State<Arc<ServerState>>, BearerToken,
and SiteName. Use it in handler signatures instead of the three
individual extractors when all three are needed (the typical case).
Extraction also validates that the X-Manta-Site value resolves to
a configured super::SiteBackend, so Self::infra inside the
handler body is infallible.
The unauthenticated /auth/* handlers and the health endpoint
still use explicit extractors — they don’t need a Bearer token.
§Example
pub async fn get_groups(ctx: RequestCtx) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
let infra = ctx.infra();
let groups = service::group::get_groups(&infra, &ctx.token).await.map_err(to_handler_error)?;
Ok(Json(groups))
}Fields§
§state: Arc<ServerState>Shared server state (backend dispatcher, per-site config, TLS material, optional Vault + k8s URLs).
token: StringBearer token extracted from the inbound Authorization header.
site_name: StringSite name extracted from the inbound X-Manta-Site header;
used to pick the right [sites.X] entry from state.
Implementations§
Source§impl RequestCtx
impl RequestCtx
Sourcepub fn infra(&self) -> InfraContext<'_>
pub fn infra(&self) -> InfraContext<'_>
Borrow the per-site infrastructure (backend, base URLs, root cert, optional Vault + k8s URLs). Infallible — the site was validated during extraction; a missing site would have failed the request before the handler body ran.
Trait Implementations§
Source§impl FromRequestParts<Arc<ServerState>> for RequestCtx
impl FromRequestParts<Arc<ServerState>> for RequestCtx
Source§type Rejection = (StatusCode, Json<ErrorResponse>)
type Rejection = (StatusCode, Json<ErrorResponse>)
Source§async fn from_request_parts(
parts: &mut Parts,
state: &Arc<ServerState>,
) -> Result<Self, Self::Rejection>
async fn from_request_parts( parts: &mut Parts, state: &Arc<ServerState>, ) -> Result<Self, Self::Rejection>
Auto Trait Implementations§
impl !RefUnwindSafe for RequestCtx
impl !UnwindSafe for RequestCtx
impl Freeze for RequestCtx
impl Send for RequestCtx
impl Sync for RequestCtx
impl Unpin for RequestCtx
impl UnsafeUnpin for RequestCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more