Skip to main content

EndpointContext

Struct EndpointContext 

Source
pub struct EndpointContext<'a, S: AuthSchema> {
    pub request: Option<&'a AuthRequest>,
    pub path: Option<&'a str>,
    pub params: HashMap<String, String>,
    pub body: FieldValue,
    pub auth: &'a AuthContext<S>,
    pub transaction: Option<&'a dyn AuthTransaction<S>>,
    pub session: Option<(UserView, SessionView)>,
    pub response: Option<&'a AuthResponse>,
    /* private fields */
}
Expand description

The parsed endpoint input and the active authentication runtime.

Fields§

§request: Option<&'a AuthRequest>

Original Request supplied by HTTP transport or an explicit native caller.

§path: Option<&'a str>

Endpoint path, including synthetic dispatch from another endpoint.

§params: HashMap<String, String>

Values captured from the matched endpoint template.

§body: FieldValue

Input after endpoint validation and unknown-field filtering.

§auth: &'a AuthContext<S>

Full typed runtime, including the store, options, metadata, and extensions.

§transaction: Option<&'a dyn AuthTransaction<S>>

Active transaction. Use this store for database work inside transactional callbacks.

§session: Option<(UserView, SessionView)>

Session already resolved by this endpoint before the callback.

§response: Option<&'a AuthResponse>

Completed response when the callback runs from an after hook.

Implementations§

Source§

impl<S: AuthSchema> EndpointContext<'_, S>

Source

pub fn to_owned(&self) -> OwnedEndpointContext<S>

Retain this endpoint for asynchronous work that may outlive its response.

Source§

impl<'a, S: AuthSchema> EndpointContext<'a, S>

Source

pub fn test(&'a self) -> AuthResult<TestUtilsApi<'a, S>>

Access installed test helpers using this endpoint’s active transaction.

Source

pub fn headers(&self) -> Option<&HashMap<String, String>>

Supplied endpoint headers, preserving omission for native calls.

Source

pub fn query(&self) -> Option<&Value>

Endpoint query, preserving native omission separately from null and an empty object.

Source

pub fn input_request(&self) -> Option<&'a AuthRequest>

Active endpoint input and shared server state, independent of the original Request.

Source

pub fn set_header(&self, name: &str, value: impl Into<String>) -> AuthResult<()>

Set a response header without replacing other header names.

Source

pub fn append_header( &self, name: &str, value: impl Into<String>, ) -> AuthResult<()>

Append a response header, including another Set-Cookie value.

Source

pub fn new_session(&self) -> AuthResult<Option<NativeSessionData>>

Identity supplied to the most recent session-cookie write in this endpoint.

Source

pub fn email_otp(&self) -> AuthResult<EmailOtpApi<'a, S>>

Use the registered Email OTP plugin within this endpoint’s active transaction.

Source

pub fn organization(&self) -> AuthResult<OrganizationApi<'a, S>>

Add organization members within this endpoint’s active transaction.

Source

pub fn phone_number(&self) -> AuthResult<PhoneNumberApi<'a, S>>

Consume a phone OTP within this endpoint’s active transaction.

Source

pub fn jwt(&self) -> AuthResult<JwtApi<'a, S>>

Use the registered JWT key adapter within this endpoint’s active transaction.

Source

pub fn native( input_request: Option<&'a AuthRequest>, original_request: Option<&'a AuthRequest>, body: FieldValue, auth: &'a AuthContext<S>, ) -> Self

Construct a native endpoint without inferring a Request from ambient HTTP activity.

Source

pub fn new( request: Option<&'a AuthRequest>, body: FieldValue, auth: &'a AuthContext<S>, ) -> Self

Construct an endpoint context from its request, validated body, and runtime. Set transaction when the caller executes inside an active database transaction.

Auto Trait Implementations§

§

impl<'a, S> !RefUnwindSafe for EndpointContext<'a, S>

§

impl<'a, S> !UnwindSafe for EndpointContext<'a, S>

§

impl<'a, S> Freeze for EndpointContext<'a, S>
where &'a AuthContext<S>: Freeze, Option<&'a dyn AuthTransaction<S>>: Freeze,

§

impl<'a, S> Send for EndpointContext<'a, S>
where &'a AuthContext<S>: Send, Option<&'a dyn AuthTransaction<S>>: Send,

§

impl<'a, S> Sync for EndpointContext<'a, S>
where &'a AuthContext<S>: Sync, Option<&'a dyn AuthTransaction<S>>: Sync,

§

impl<'a, S> Unpin for EndpointContext<'a, S>
where &'a AuthContext<S>: Unpin, Option<&'a dyn AuthTransaction<S>>: Unpin,

§

impl<'a, S> UnsafeUnpin for EndpointContext<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more