Skip to main content

RequestCtx

Struct RequestCtx 

Source
pub struct RequestCtx<'a> {
    pub req: &'a HttpRequest,
    pub params: RouteParams,
    pub query: QueryMap,
    pub mount: MountPrefix,
    pub htmx: HtmxInfo,
    pub session: Option<SessionCtx>,
    /* private fields */
}
Expand description

Unified per-request context passed to Web UI views and handlers.

Fields§

§req: &'a HttpRequest§params: RouteParams§query: QueryMap§mount: MountPrefix§htmx: HtmxInfo§session: Option<SessionCtx>

Implementations§

Source§

impl<'a> RequestCtx<'a>

Source

pub fn new(req: &'a HttpRequest, mount: MountPrefix) -> Self

Source

pub fn with_params(self, params: RouteParams) -> Self

Source

pub fn with_session(self, session: Option<SessionCtx>) -> Self

Source

pub fn csrf_token(&self) -> Option<&str>

Return the bound CSRF token if a browser session is active.

Source

pub fn path(&self, rel: &str) -> String

Build a mount-aware relative URL (e.g. "/issues" -> "/alpha/issues").

Source

pub fn url(&self, route: AppRoute<'_>) -> String

Build a typed route URL via super::route::AppRoute.

Trait Implementations§

Source§

impl UiCtx for RequestCtx<'_>

Source§

fn mount(&self) -> &MountPrefix

Source§

fn htmx(&self) -> &HtmxInfo

Source§

fn session(&self) -> Option<&SessionCtx>

Source§

fn csrf_token(&self) -> Option<&str>

Source§

fn path(&self, rel: &str) -> String

Source§

fn url(&self, route: AppRoute<'_>) -> String

Auto Trait Implementations§

§

impl<'a> Forget for RequestCtx<'a>

§

impl<'a> Freeze for RequestCtx<'a>
where &'a HttpRequest: Freeze, *const u8 is !null: Freeze, PhantomData<(String, String)>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, String)>>: Freeze, PhantomData<u8>: Freeze, *const ArcInner<ForgeStore> is !null: Freeze, PhantomData<ArcInner<ForgeStore>>: Freeze,

§

impl<'a> Move for RequestCtx<'a>

§

impl<'a> RefUnwindSafe for RequestCtx<'a>

§

impl<'a> Send for RequestCtx<'a>
where &'a HttpRequest: Send, RawVecInner: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, Arc<ForgeStore>: Send,

§

impl<'a> Sync for RequestCtx<'a>
where RawVecInner: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, Arc<ForgeStore>: Sync,

§

impl<'a> Unpin for RequestCtx<'a>
where &'a HttpRequest: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, Arc<ForgeStore>: Unpin,

§

impl<'a> UnsafeUnpin for RequestCtx<'a>
where &'a HttpRequest: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<(String, String)>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<ForgeStore> is !null: UnsafeUnpin, PhantomData<ArcInner<ForgeStore>>: UnsafeUnpin,

§

impl<'a> UnwindSafe for RequestCtx<'a>
where &'a HttpRequest: UnwindSafe, RawVecInner: UnwindSafe, BTreeMap<String, String>: UnwindSafe, Arc<ForgeStore>: UnwindSafe,

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<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, 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> 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.