Skip to content

Instantly share code, notes, and snippets.

@withoutboats
Created May 17, 2017 00:45
Show Gist options
  • Save withoutboats/b7574723bf92d28d954d439fd930daf9 to your computer and use it in GitHub Desktop.
Save withoutboats/b7574723bf92d28d954d439fd930daf9 to your computer and use it in GitHub Desktop.
#[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