pub struct HttpTemplate {
pub template_type: Option<String>,
pub template: Option<String>,
pub template_file: Option<String>,
}Expand description
Template action — evaluate a response or forward template (Velocity, Mustache, etc.).
Used as httpResponseTemplate or httpForwardTemplate in an expectation.
§Example
use mockserver_client::HttpTemplate;
let tmpl = HttpTemplate::new("VELOCITY", "{ \"statusCode\": 200 }")
.template_file("/path/to/template.vm");Fields§
§template_type: Option<String>§template: Option<String>§template_file: Option<String>Implementations§
Source§impl HttpTemplate
impl HttpTemplate
Sourcepub fn new(
template_type: impl Into<String>,
template: impl Into<String>,
) -> Self
pub fn new( template_type: impl Into<String>, template: impl Into<String>, ) -> Self
Create a template action with the given type and inline template body.
Sourcepub fn from_file(
template_type: impl Into<String>,
file_path: impl Into<String>,
) -> Self
pub fn from_file( template_type: impl Into<String>, file_path: impl Into<String>, ) -> Self
Create a template action that loads from a file path.
Sourcepub fn template_type(self, template_type: impl Into<String>) -> Self
pub fn template_type(self, template_type: impl Into<String>) -> Self
Set the template type (e.g., “VELOCITY”, “MUSTACHE”).
Sourcepub fn template_file(self, file_path: impl Into<String>) -> Self
pub fn template_file(self, file_path: impl Into<String>) -> Self
Set the template file path (alternative to inline template).
Trait Implementations§
Source§impl Clone for HttpTemplate
impl Clone for HttpTemplate
Source§fn clone(&self) -> HttpTemplate
fn clone(&self) -> HttpTemplate
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 HttpTemplate
impl Debug for HttpTemplate
Source§impl Default for HttpTemplate
impl Default for HttpTemplate
Source§fn default() -> HttpTemplate
fn default() -> HttpTemplate
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for HttpTemplate
impl<'de> Deserialize<'de> for HttpTemplate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for HttpTemplate
impl PartialEq for HttpTemplate
Source§fn eq(&self, other: &HttpTemplate) -> bool
fn eq(&self, other: &HttpTemplate) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for HttpTemplate
impl Serialize for HttpTemplate
impl StructuralPartialEq for HttpTemplate
Auto Trait Implementations§
impl Freeze for HttpTemplate
impl RefUnwindSafe for HttpTemplate
impl Send for HttpTemplate
impl Sync for HttpTemplate
impl Unpin for HttpTemplate
impl UnsafeUnpin for HttpTemplate
impl UnwindSafe for HttpTemplate
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