Trivial HTTP response
This commit is contained in:
parent
aae43917e2
commit
9eb48f7ddc
2 changed files with 15 additions and 3 deletions
|
@ -1,7 +1,9 @@
|
||||||
#[macro_use] extern crate diesel;
|
#[macro_use] extern crate diesel;
|
||||||
#[macro_use] extern crate diesel_codegen;
|
#[macro_use] extern crate diesel_codegen;
|
||||||
|
#[macro_use] extern crate lazy_static;
|
||||||
|
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
extern crate futures;
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
16
src/site.rs
16
src/site.rs
|
@ -1,8 +1,13 @@
|
||||||
extern crate futures;
|
use futures::{self, Future};
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
|
use hyper::header::ContentType;
|
||||||
|
use hyper::mime;
|
||||||
use hyper::server::*;
|
use hyper::server::*;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref TEXT_HTML: mime::Mime = "text/html;charset=utf-8".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Site {
|
pub struct Site {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +18,11 @@ impl Service for Site {
|
||||||
type Future = futures::BoxFuture<Response, Self::Error>;
|
type Future = futures::BoxFuture<Response, Self::Error>;
|
||||||
|
|
||||||
fn call(&self, _req: Request) -> Self::Future {
|
fn call(&self, _req: Request) -> Self::Future {
|
||||||
unimplemented!()
|
futures::finished(
|
||||||
|
Response::new()
|
||||||
|
.with_header(ContentType(TEXT_HTML.clone()))
|
||||||
|
.with_body(format!("WOOOOOOOOOOT!"))
|
||||||
|
.with_status(hyper::StatusCode::Ok)
|
||||||
|
).boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue