pub struct Response {
pub status: u16,
pub headers: HashMap<String, String>,
pub body: Value,
}Expand description
HTTP response returned by plugin handlers.
Fields§
§status: u16HTTP status code
headers: HashMap<String, String>Response headers
body: ValueResponse body
Implementations§
Source§impl Response
impl Response
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 from_error(err: &Error) -> Self
pub fn from_error(err: &Error) -> Self
Create a response from an SDK Error
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Add a header to the response
Sourcepub fn content_type(self, content_type: &str) -> Self
pub fn content_type(self, content_type: &str) -> Self
Set Content-Type header
Sourcepub fn cache_control(self, value: &str) -> Self
pub fn cache_control(self, value: &str) -> Self
Set Cache-Control header
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
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