2019-06-17 15:15:33 -04:00
|
|
|
// <identity-two>
|
|
|
|
use actix_web::{
|
2019-06-28 13:31:30 -04:00
|
|
|
http::ContentEncoding, middleware, middleware::BodyEncoding, HttpResponse,
|
2019-06-17 15:15:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static HELLO_WORLD: &[u8] = &[
|
|
|
|
0x1f, 0x8b, 0x08, 0x00, 0xa2, 0x30, 0x10, 0x5c, 0x00, 0x03, 0xcb, 0x48, 0xcd, 0xc9,
|
|
|
|
0xc9, 0x57, 0x28, 0xcf, 0x2f, 0xca, 0x49, 0xe1, 0x02, 0x00, 0x2d, 0x3b, 0x08, 0xaf,
|
|
|
|
0x0c, 0x00, 0x00, 0x00,
|
|
|
|
];
|
|
|
|
|
2019-06-28 13:31:30 -04:00
|
|
|
pub fn index() -> HttpResponse {
|
2019-06-17 15:15:33 -04:00
|
|
|
HttpResponse::Ok()
|
|
|
|
.encoding(ContentEncoding::Identity)
|
|
|
|
.header("content-encoding", "gzip")
|
|
|
|
.body(HELLO_WORLD)
|
|
|
|
}
|
|
|
|
// </identity-two>
|
2019-06-19 00:20:50 -04:00
|
|
|
|
|
|
|
pub fn main() {
|
2019-06-26 01:58:47 -04:00
|
|
|
use actix_web::{web, App, HttpServer};
|
|
|
|
|
2019-06-26 14:15:03 -04:00
|
|
|
HttpServer::new(|| {
|
|
|
|
App::new()
|
|
|
|
.wrap(middleware::Compress::default())
|
|
|
|
.route("/", web::get().to(index))
|
|
|
|
})
|
|
|
|
.bind("127.0.0.1:8088")
|
|
|
|
.unwrap()
|
|
|
|
.run()
|
|
|
|
.unwrap();
|
2019-06-19 00:20:50 -04:00
|
|
|
}
|