pub struct TemplateContext {
pub path: HashMap<String, String>,
pub query: HashMap<String, String>,
pub headers: HashMap<String, String>,
pub body: Value,
}Expand description
Lookup tables used while rendering templates.
Fields§
§path: HashMap<String, String>Captured path parameters (e.g. {"id": "42"}).
query: HashMap<String, String>Query parameters.
headers: HashMap<String, String>Request headers. Keys are expected to be lower-cased.
body: ValueParsed JSON request body (Value::Null when the body was not JSON).
Implementations§
Source§impl TemplateContext
impl TemplateContext
Sourcepub fn lookup(&self, expression: &str) -> Option<String>
pub fn lookup(&self, expression: &str) -> Option<String>
Resolve an expression to a string value.
The expression may be:
- a helper function name (with or without arguments),
path.<key>,query.<key>,header.<key>, orbody.<json.path>(dot navigation through objects/arrays).
Returns None when the expression is unknown or the value is absent.
Helper functions never return None.
Trait Implementations§
Source§impl Clone for TemplateContext
impl Clone for TemplateContext
Source§fn clone(&self) -> TemplateContext
fn clone(&self) -> TemplateContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TemplateContext
impl Debug for TemplateContext
Source§impl Default for TemplateContext
impl Default for TemplateContext
Source§fn default() -> TemplateContext
fn default() -> TemplateContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TemplateContext
impl RefUnwindSafe for TemplateContext
impl Send for TemplateContext
impl Sync for TemplateContext
impl Unpin for TemplateContext
impl UnsafeUnpin for TemplateContext
impl UnwindSafe for TemplateContext
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