Hyperap - Hyper wrapper. A very minimal wrapper for Hyper.rs to create a working webserver.
~~~rs extern crate hyperap; use hyperap::hyper::server::{Response}; use hyperap::hyper::{Method}; use hyperap::server::{HyperApp, Middleware, MiddlewareParam}; use hyperap::response::{resp};
fn getstatic(a: MiddlewareResult) -> Response { hyperap::server::staticfile("Cargo.toml") } fn helloworld(a: MiddlewareResult) -> Response { resp(a.hello.clone() + " at path " + &a.path) } fn notfoundroute(a: MiddlewareResult) -> Response { resp("not found route at path ".to_owned() + &a.path) } pub struct App { pub hello: String, } pub struct MiddlewareResult { path: String, hello: String, }
pub struct RouteDefinition {
parameters: Vec
pub struct RouteDefinitionParameters {
in: String,
name: String,
}
impl Middleware for App {
type M = MiddlewareResult;
type R = RouteDefinition;
fn middleware(&self, p: MiddlewareParam