pub struct LambdaResponse {
pub status: u16,
pub headers: Vec<(String, String)>,
pub body: Bytes,
pub is_base64: bool,
}Expand description
Lambda HTTP response.
Fields§
§status: u16Status code.
headers: Vec<(String, String)>Response headers, in emission order.
A list rather than a map because HTTP allows the same field name to
appear more than once and a handler must be able to use that — most
importantly to emit several Set-Cookie lines, which cannot legally be
folded into one. A map would silently keep only the last one.
body: BytesResponse body.
is_base64: boolWhether body is base64 encoded.
Implementations§
Source§impl LambdaResponse
impl LambdaResponse
Sourcepub fn internal_error(message: impl Into<String>) -> Self
pub fn internal_error(message: impl Into<String>) -> Self
Create an internal server error response.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Append a header.
Appends rather than replaces, so calling this twice with the same name
emits two header lines (e.g. two Set-Cookies). Use set_header to
replace instead.
Sourcepub fn set_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn set_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Set a header, removing any existing lines with the same name.
Sourcepub fn header_value(&self, name: &str) -> Option<&str>
pub fn header_value(&self, name: &str) -> Option<&str>
The first value for name, matched case-insensitively.
Sourcepub fn header_values<'a, 'n>(
&'a self,
name: &'n str,
) -> impl Iterator<Item = &'a str> + use<'a, 'n>
pub fn header_values<'a, 'n>( &'a self, name: &'n str, ) -> impl Iterator<Item = &'a str> + use<'a, 'n>
Every value for name, in emission order, matched case-insensitively.
Sourcepub fn content_type(self, content_type: impl Into<String>) -> Self
pub fn content_type(self, content_type: impl Into<String>) -> Self
Set content type.
Sourcepub fn into_lambda_response(self) -> Response<Body>
pub fn into_lambda_response(self) -> Response<Body>
Convert to lambda_http::Response.