Created
May 17, 2017 00:45
-
-
Save withoutboats/b7574723bf92d28d954d439fd930daf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] extern crate cargonauts; | |
use cargonauts::futures::{Future, future}; | |
use cargonauts::resources::{Resource, Environment, Error}; | |
use cargonauts::methods::Get; | |
use cargonauts::formats::Debug; | |
routes! { | |
resource Echo { | |
method Get in Debug; | |
} | |
} | |
#[derive(Debug)] | |
struct Echo(String); | |
impl Resource for Echo { | |
type Identifier = String; | |
} | |
impl Get for Echo { | |
fn get(id: String, _: &mut Environment) -> Box<Future<Item = Echo, Error = Error>> { | |
Box::new(future::ok(Echo(id))) | |
} | |
} | |
fn main() { | |
cargonauts::serve(routes).unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment