pub struct HttpSseResponse {
pub status_code: Option<u16>,
pub headers: Option<HashMap<String, Vec<String>>>,
pub events: Option<Vec<SseEvent>>,
pub close_connection: Option<bool>,
pub delay: Option<Delay>,
pub template_type: Option<String>,
pub primary: Option<bool>,
pub extra: Extra,
}Expand description
Builder for a Server-Sent Events (SSE) streaming response action.
Serialized as the httpSseResponse action in an expectation.
§Example
use mockserver_client::{HttpSseResponse, SseEvent};
let sse = HttpSseResponse::new()
.status_code(200)
.header("Content-Type", "text/event-stream")
.event(SseEvent::new().event("message").data("hello").id("1"))
.close_connection(true);Fields§
§status_code: Option<u16>§headers: Option<HashMap<String, Vec<String>>>§events: Option<Vec<SseEvent>>§close_connection: Option<bool>§delay: Option<Delay>§template_type: Option<String>§primary: Option<bool>§extra: ExtraCatch-all for server fields this client does not model yet, so a retrieve -> re-submit cycle cannot silently destroy them.
Implementations§
Source§impl HttpSseResponse
impl HttpSseResponse
Sourcepub fn status_code(self, code: u16) -> Self
pub fn status_code(self, code: u16) -> Self
Set the HTTP status code.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a response header.
Sourcepub fn close_connection(self, close: bool) -> Self
pub fn close_connection(self, close: bool) -> Self
Whether to close the connection after emitting all events.
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 (VELOCITY, JAVASCRIPT or MUSTACHE).
Trait Implementations§
Source§impl Clone for HttpSseResponse
impl Clone for HttpSseResponse
Source§fn clone(&self) -> HttpSseResponse
fn clone(&self) -> HttpSseResponse
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 HttpSseResponse
impl Debug for HttpSseResponse
Source§impl Default for HttpSseResponse
impl Default for HttpSseResponse
Source§fn default() -> HttpSseResponse
fn default() -> HttpSseResponse
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for HttpSseResponse
impl<'de> Deserialize<'de> for HttpSseResponse
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 HttpSseResponse
impl PartialEq for HttpSseResponse
Source§impl Serialize for HttpSseResponse
impl Serialize for HttpSseResponse
impl StructuralPartialEq for HttpSseResponse
Auto Trait Implementations§
impl Freeze for HttpSseResponse
impl RefUnwindSafe for HttpSseResponse
impl Send for HttpSseResponse
impl Sync for HttpSseResponse
impl Unpin for HttpSseResponse
impl UnsafeUnpin for HttpSseResponse
impl UnwindSafe for HttpSseResponse
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