[−][src]Struct srvrls::request::SrvrlsRequest
This replaces the inbound Request
and Context
entity with simpler, opinionated methods.
The data members can be used directly or one of the provided helper functions can simplify
access by providing sensible defaults (e.g., empty string) to simplify match statements.
E.g.,
fn test_handler(request: SrvrlsRequest) -> Result<SrvrlsResponse,SrvrlsError> { match (&request.method, request.path_parameter(0).as_str()) { (HttpMethod::POST, "customer") => Ok(SrvrlsResponse::no_content()), (HttpMethod::POST, "account") => Ok(SrvrlsResponse::created()), (HttpMethod::GET, "customer") => Ok(SrvrlsResponse::ok_empty()), _ => return Err(SrvrlsError::NotFound) } } let mut request : SrvrlsRequest = Default::default(); request.method = HttpMethod::POST; request.path = "customer/CUST-A23948".to_string(); assert_eq!(SrvrlsResponse::no_content(), test_handler(request).unwrap()); let mut request : SrvrlsRequest = Default::default(); request.method = HttpMethod::POST; request.path = "account/ACCT-G10291".to_string(); assert_eq!(SrvrlsResponse::created(), test_handler(request).unwrap()); let mut request : SrvrlsRequest = Default::default(); request.method = HttpMethod::GET; request.path = "customer/CUST-A23948".to_string(); assert_eq!(SrvrlsResponse::ok_empty(), test_handler(request).unwrap()); let mut request : SrvrlsRequest = Default::default(); request.method = HttpMethod::GET; request.path = "account/ACCT-G10291".to_string(); assert_eq!(SrvrlsError::NotFound, test_handler(request).unwrap_err());
Fields
query_parameters: HashMap<String, Vec<String>>
All query parameters in a map by key value.
path: String
The path of the request. This is taken from the inbound event field path_parameter
for
that has the value proxy
.
This value is always provided without a leading '/'
string_claims: HashMap<String, String>
All String claims within the authorizer field.
integer_claims: HashMap<String, i64>
All Numeric (i64) claims within the authorizer field.
method: HttpMethod
The HttpMethod
of the request.
body: String
The request payload, or empty String if none exists.
Methods
impl SrvrlsRequest
[src]
pub fn path_parameter(&self, position: usize) -> String
[src]
Provides the path parameter as a String, if the parameter is missing an empty string will be returned in its' stead.
fn test_handler(request: SrvrlsRequest) -> Result<SrvrlsResponse,SrvrlsError> { match (&request.method, request.path_parameter(0).as_str()) { (HttpMethod::POST, "customer") => Ok(SrvrlsResponse::no_content()), (HttpMethod::POST, "account") => Ok(SrvrlsResponse::created()), (HttpMethod::GET, "customer") => Ok(SrvrlsResponse::ok_empty()), _ => return Err(SrvrlsError::NotFound) } } let mut request : SrvrlsRequest = Default::default(); request.path = "customer/update/CUST-A23948".to_string(); assert_eq!("customer", request.path_parameter(0)); assert_eq!("update", request.path_parameter(1)); assert_eq!("CUST-A23948", request.path_parameter(2));
pub fn query_parameter(&self, key: &str) -> Vec<String>
[src]
Returns a Vec<String>
for a requested query parameter
pub fn authentication_claim(&self, claim: &str) -> String
[src]
This provides access to authentication claims (in AWS Lambda Proxy calls) that are String
s.
This signature is likely to change with Azure and Google Cloud Function implemenations.
Trait Implementations
impl Default for SrvrlsRequest
[src]
impl From<ApiGatewayProxyRequest> for SrvrlsRequest
[src]
fn from(event: ApiGatewayProxyRequest) -> Self
[src]
Auto Trait Implementations
impl RefUnwindSafe for SrvrlsRequest
impl Send for SrvrlsRequest
impl Sync for SrvrlsRequest
impl Unpin for SrvrlsRequest
impl UnwindSafe for SrvrlsRequest
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,