Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

tomusdrw/resty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Resty

Resty - a simple JSON REST-API framework for Rust.

Build Status

Documentation

Examples

extern crate futures;
extern crate resty;
#[macro_use]
extern crate serde_derive;

use futures::Future;

#[derive(Deserialize, Serialize)]
struct Call {
    pub test: u64,
}

fn main() {
    let mut server = resty::Router::new();

    server.get("/", |_| {
        Ok("Hello World!") as Result<_, resty::Error>
    });

    server.post("/", |request| {
        // Deserialize payload
        request.json().map(|mut call: Call| {
            call.test += 1;
            // And return the same payload as a response
            call
        })
    });

    // Print out supported routes.
    println!("{}", server.routes());

    let listening = server.bind("localhost:3000").unwrap();
    listening.wait()
}

For more see examples folder.

TODO

General

  • get_*() for dynamic params.
  • Auto handle HEAD/OPTIONS requests.
  • CORS support
  • Middlewares
  • Cache Control
  • Auto-derive Into<Router> for structs.
  • Query parameters
  • Optional parameters
  • Parameters with /

About

A simple JSON REST API framework.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages