Started to work on server

This commit is contained in:
Thomas Forgione 2018-09-24 14:32:12 +02:00
parent fb28f2bc6e
commit b7bb4f5964
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
5 changed files with 30 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target
**/*.rs.bk
Cargo.lock

View File

@ -4,3 +4,12 @@ version = "0.1.0"
authors = ["Thomas Forgione <thomas@forgione.fr>"]
[dependencies]
hyper = "0.12.10"
[[bin]]
name = "mars-server"
path = "src/server.rs"
[[bin]]
name = "mars"
path = "src/client.rs"

1
src/lib.rs Normal file
View File

@ -0,0 +1 @@
extern crate hyper;

19
src/server.rs Normal file
View File

@ -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(())
}));
}