Struct worker::RouteContext
source · pub struct RouteContext<D> {
pub data: D,
pub env: Env,
/* private fields */
}
Expand description
Container for a route’s parsed parameters, data, and environment bindings from the Runtime (such as KV Stores, Durable Objects, Variables, and Secrets).
Fields§
§data: D
§env: Env
Implementations§
source§impl<D> RouteContext<D>
impl<D> RouteContext<D>
sourcepub fn data(&self) -> &D
👎Deprecated since 0.0.8: please use the data
field directly
pub fn data(&self) -> &D
data
field directlyGet a reference to the generic associated data provided to the Router
.
sourcepub fn get_env(self) -> Env
👎Deprecated since 0.0.8: please use the env
field directly
pub fn get_env(self) -> Env
env
field directlyGet the Env
for this Worker. Typically users should opt for the secret
, var
, kv
and
durable_object
methods on the RouteContext
instead.
sourcepub fn secret(&self, binding: &str) -> Result<Secret>
pub fn secret(&self, binding: &str) -> Result<Secret>
Get a Secret value associated with this Worker, should one exist.
sourcepub fn var(&self, binding: &str) -> Result<Var>
pub fn var(&self, binding: &str) -> Result<Var>
Get an Environment Variable value associated with this Worker, should one exist.
sourcepub fn kv(&self, binding: &str) -> Result<KvStore>
pub fn kv(&self, binding: &str) -> Result<KvStore>
Get a KV Namespace associated with this Worker, should one exist.
sourcepub fn durable_object(&self, binding: &str) -> Result<ObjectNamespace>
pub fn durable_object(&self, binding: &str) -> Result<ObjectNamespace>
Get a Durable Object Namespace associated with this Worker, should one exist.
sourcepub fn param(&self, key: &str) -> Option<&String>
pub fn param(&self, key: &str) -> Option<&String>
Get a URL parameter parsed by the router, by the name of its match or wildecard placeholder.
Auto Trait Implementations§
impl<D> RefUnwindSafe for RouteContext<D>where D: RefUnwindSafe,
impl<D> !Send for RouteContext<D>
impl<D> !Sync for RouteContext<D>
impl<D> Unpin for RouteContext<D>where D: Unpin,
impl<D> UnwindSafe for RouteContext<D>where D: UnwindSafe,
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
Mutably borrows from an owned value. Read more