pub struct HttpTriggerResponse {
pub status: u16,
pub headers: Value,
pub body: Value,
}Expand description
Response from an HTTP trigger function.
Functions should return this format as JSON.
Fields§
§status: u16HTTP status code (default 200).
headers: ValueResponse headers.
body: ValueResponse body.
Implementations§
Source§impl HttpTriggerResponse
impl HttpTriggerResponse
Sourcepub fn with_status(status: u16, body: Value) -> Self
pub fn with_status(status: u16, body: Value) -> Self
Create a response with custom status and body.
Sourcepub fn no_content() -> Self
pub fn no_content() -> Self
Create a 204 No Content response.
Sourcepub fn bad_request(message: &str) -> Self
pub fn bad_request(message: &str) -> Self
Create a 400 Bad Request response.
Create a 401 Unauthorized response.
Sourcepub fn internal_error(message: &str) -> Self
pub fn internal_error(message: &str) -> Self
Create a 500 Internal Server Error response.
Sourcepub fn with_header(self, key: String, value: String) -> Self
pub fn with_header(self, key: String, value: String) -> Self
Add a header to the response.
Trait Implementations§
Source§impl Clone for HttpTriggerResponse
impl Clone for HttpTriggerResponse
Source§fn clone(&self) -> HttpTriggerResponse
fn clone(&self) -> HttpTriggerResponse
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 HttpTriggerResponse
impl Debug for HttpTriggerResponse
Source§impl<'de> Deserialize<'de> for HttpTriggerResponse
impl<'de> Deserialize<'de> for HttpTriggerResponse
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 HttpTriggerResponse
impl RefUnwindSafe for HttpTriggerResponse
impl Send for HttpTriggerResponse
impl Sync for HttpTriggerResponse
impl Unpin for HttpTriggerResponse
impl UnsafeUnpin for HttpTriggerResponse
impl UnwindSafe for HttpTriggerResponse
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