pub struct MockRequest {Show 15 fields
pub id: EntityId,
pub name: String,
pub description: Option<String>,
pub method: HttpMethod,
pub path: String,
pub headers: HashMap<String, String>,
pub query_params: HashMap<String, String>,
pub body: Option<String>,
pub response: MockResponse,
pub response_history: Vec<ResponseHistoryEntry>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub tags: Vec<String>,
pub auth: Option<AuthConfig>,
pub priority: i32,
}
Expand description
Mock request definition with metadata
Fields§
§id: EntityId
Unique identifier
name: String
Human-readable name
description: Option<String>
Optional description
method: HttpMethod
HTTP method
path: String
Request path
headers: HashMap<String, String>
HTTP headers
query_params: HashMap<String, String>
Query parameters
body: Option<String>
Request body template
response: MockResponse
Expected response
response_history: Vec<ResponseHistoryEntry>
History of actual request executions
created_at: DateTime<Utc>
Creation timestamp
updated_at: DateTime<Utc>
Last modification timestamp
Associated tags
auth: Option<AuthConfig>
Authentication configuration
priority: i32
Priority for route matching (higher = more specific)
Implementations§
Source§impl MockRequest
impl MockRequest
Sourcepub fn apply_inheritance(
&mut self,
effective_headers: HashMap<String, String>,
effective_auth: Option<&AuthConfig>,
)
pub fn apply_inheritance( &mut self, effective_headers: HashMap<String, String>, effective_auth: Option<&AuthConfig>, )
Apply inheritance to this request, returning headers and auth from the hierarchy
Sourcepub fn create_inherited_request(
self,
workspace: &Workspace,
folder_path: &[&Folder],
) -> Self
pub fn create_inherited_request( self, workspace: &Workspace, folder_path: &[&Folder], ) -> Self
Create inherited request with merged headers and auth
Sourcepub fn new(method: HttpMethod, path: String, name: String) -> Self
pub fn new(method: HttpMethod, path: String, name: String) -> Self
Create a new mock request
Sourcepub fn with_response(self, response: MockResponse) -> Self
pub fn with_response(self, response: MockResponse) -> Self
Set the response for this request
Sourcepub fn with_header(self, key: String, value: String) -> Self
pub fn with_header(self, key: String, value: String) -> Self
Add a header
Sourcepub fn with_query_param(self, key: String, value: String) -> Self
pub fn with_query_param(self, key: String, value: String) -> Self
Add a query parameter
Sourcepub fn add_response_history(&mut self, entry: ResponseHistoryEntry)
pub fn add_response_history(&mut self, entry: ResponseHistoryEntry)
Add a response history entry
Sourcepub fn get_response_history(&self) -> &[ResponseHistoryEntry]
pub fn get_response_history(&self) -> &[ResponseHistoryEntry]
Get response history (sorted by execution time, newest first)
Trait Implementations§
Source§impl Clone for MockRequest
impl Clone for MockRequest
Source§fn clone(&self) -> MockRequest
fn clone(&self) -> MockRequest
Returns a duplicate of the value. Read more
1.0.0 · 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 MockRequest
impl Debug for MockRequest
Source§impl<'de> Deserialize<'de> for MockRequest
impl<'de> Deserialize<'de> for MockRequest
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
Auto Trait Implementations§
impl Freeze for MockRequest
impl RefUnwindSafe for MockRequest
impl Send for MockRequest
impl Sync for MockRequest
impl Unpin for MockRequest
impl UnwindSafe for MockRequest
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