31 releases

new 0.0.37 Nov 19, 2020
0.0.32 Oct 10, 2020
0.0.26 Jul 30, 2020
0.0.18 Mar 1, 2020

#263 in Procedural macros

Download history 3/week @ 2020-08-04 67/week @ 2020-08-11 30/week @ 2020-08-18 31/week @ 2020-08-25 52/week @ 2020-09-01 89/week @ 2020-09-08 294/week @ 2020-09-15 279/week @ 2020-09-22 86/week @ 2020-09-29 227/week @ 2020-10-06 135/week @ 2020-10-13 77/week @ 2020-10-20 195/week @ 2020-10-27 138/week @ 2020-11-03 171/week @ 2020-11-10 253/week @ 2020-11-17

632 downloads per month
Used in 2 crates

MIT/Apache

38KB
973 lines

Mendes: web toolkit for impatient perfectionists

Documentation Crates.io Build status Coverage status License: MIT License: Apache 2.0

Mendes is a Rust web toolkit for impatient perfectionists (apologies to Django). It aims to be:

  • Modular: less framework, more library; pick and choose components
  • Async: async/await from the start
  • Low boilerplate: easy to get started, but with limited "magic"
  • Type-safe: leverage the type system to make error handling low effort
  • Secure: provide security by default; no unsafe code in this project
  • Run on stable Rust (no promises on MSRV though)

Mendes is currently in an extremely early phase and probably not ready for anything but experiments for those who are curious. Feedback is always welcome though!

Minimal example

This should definitely become more minimal over time.

use async_trait::async_trait;
use http::{Response, StatusCode};
use hyper::Body;
use mendes::{dispatch, get, Application, ClientError, Context};

#[get]
async fn hello(_: &App) -> Result<Response<Body>, Error> {
    Ok(Response::builder()
        .status(StatusCode::OK)
        .body("Hello, world".into())
        .unwrap())
}

struct App {}

#[async_trait]
impl Application for App {
    type RequestBody = ();
    type ResponseBody = Body;
    type Error = Error;

    #[dispatch]
    async fn handle(mut cx: Context<Self>) -> Response<Body> {
        path! {
            _ => hello,
        }
    }

    fn error(&self, _: Error) -> Response<Body> {
        Response::builder()
            .status(StatusCode::INTERNAL_SERVER_ERROR)
            .body("ERROR".into())
            .unwrap()
    }
}

#[derive(Debug)]
enum Error {
    Client(ClientError),
}

impl From<ClientError> for Error {
    fn from(e: ClientError) -> Error {
        Error::Client(e)
    }
}

All feedback welcome. Feel free to file bugs, requests for documentation and any other feedback to the issue tracker.

Mendes was created and is maintained by Dirkjan Ochtman.

Dependencies

~0.4–0.8MB
~21K SLoC