lando v0.2.1 Release Notes

Release Date: 2018-11-28 // over 3 years ago
    • ๐Ÿ›  fix version referenced in docs

Previous changes from v0.1.1

    • ๐Ÿ› bug fix - support for reading host from "host" (lowercase) in addition to "Host"
    • ๐Ÿ”‹ feature - add support for "application/x-www-form-urlencoded" and "application/json" parsed request bodies with lando::RequestExt#payload()
    #[macro_use] extern crate cpython;
    #[macro_use] extern crate lando;
    #[macro_use] extern crate serde_deserialize;
    
    use lando::{Response, RequestEx};
    
    #[derive(Deserialize, Debug)]
    struct Params {
      x: usize,
      y: usize
    }
    
    gateway!(
      |req, _| => Ok(
        Response::new(
          req.payload::<Params>().unwrap_or_else(|_| None).map(
            |params| format!(
              "the answer is {}", params.x + params.y
            )
          ).unwrap_or_else(
            || "try again".to_string()
          )
        )
      )
    );