[][src]Trait lando::RequestExt

pub trait RequestExt {
    fn query_string_parameters(&self) -> StrMap;
fn path_parameters(&self) -> StrMap;
fn stage_variables(&self) -> StrMap;
fn request_context(&self) -> RequestContext;
fn payload<D>(&self) -> Result<Option<D>, PayloadError>
    where
        D: Deserialize<'de>
; }

Extentions for lando::Request structs that provide access to API gateway features

In addition, you can also access a request's body in deserialized format for payloads sent in application/x-www-form-urlencoded or application/x-www-form-urlencoded format

#[macro_use] extern crate lando;
#[macro_use] extern crate serde_derive;

use lando::{Response, RequestExt};

#[derive(Debug,Deserialize,Default)]
struct Args {
  #[serde(default)]
  x: usize,
  #[serde(default)]
  y: usize
}

gateway!(|request, _| {
  let args: Args = request.payload()
    .unwrap_or_else(|_parse_err| None)
    .unwrap_or_default();
  Ok(
     Response::new(
       format!(
         "{} + {} = {}",
         args.x,
         args.y,
         args.x + args.y
       )
     )
  )
});

Required Methods

Return pre-parsed http query string parameters, parameters provided after the ? portion of a url, associated with the API gateway request. No query parameters will yield an empty StrMap.

Return pre-extracted path parameters, parameter provided in url placeholders /foo/{bar}/baz/{boom}, associated with the API gateway request. No path parameters will yield an empty StrMap

Return stage variables associated with the API gateway request. No stage parameters will yield an empty StrMap

Return request context data assocaited with the API gateway request

Return the Result of a payload parsed into a serde Deserializeable type

Currently only application/x-www-form-urlencoded and application/json flavors of content type are supported

A PayloadError will be returned for undeserializable payloads. If no body is provided, Ok(None) will be returned.

Implementations on Foreign Types

impl RequestExt for HttpRequest<Body>
[src]

Implementors