Started to work on server
This commit is contained in:
parent
fb28f2bc6e
commit
b7bb4f5964
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
Cargo.lock
|
||||||
|
|
|
@ -4,3 +4,12 @@ version = "0.1.0"
|
||||||
authors = ["Thomas Forgione <thomas@forgione.fr>"]
|
authors = ["Thomas Forgione <thomas@forgione.fr>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
hyper = "0.12.10"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "mars-server"
|
||||||
|
path = "src/server.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "mars"
|
||||||
|
path = "src/client.rs"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
extern crate hyper;
|
|
@ -0,0 +1,19 @@
|
||||||
|
extern crate hyper;
|
||||||
|
|
||||||
|
use hyper::{Body, Response, Server};
|
||||||
|
use hyper::service::service_fn_ok;
|
||||||
|
use hyper::rt::{self, Future};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
|
||||||
|
let addr = ([127, 0, 0, 1], 1500).into();
|
||||||
|
|
||||||
|
rt::run(rt::lazy(move || {
|
||||||
|
let server = Server::bind(&addr)
|
||||||
|
.serve(|| service_fn_ok(|_| Response::new(Body::from("Hello world"))))
|
||||||
|
.map_err(|e| eprintln!("server 1 error: {}", e));
|
||||||
|
|
||||||
|
rt::spawn(server);
|
||||||
|
Ok(())
|
||||||
|
}));
|
||||||
|
}
|
Loading…
Reference in New Issue