1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 09:59:21 +02:00

update examples

This commit is contained in:
Nikolay Kim
2017-11-29 14:03:18 -08:00
parent acc2fff655
commit ffb2e3c0ab
2 changed files with 31 additions and 42 deletions

View File

@ -9,12 +9,12 @@ use std::io::Read;
use actix_web::*;
/// somple handle
fn index(req: HttpRequest) -> HttpResponse {
fn index(req: HttpRequest) -> Result<HttpResponse> {
println!("{:?}", req);
httpcodes::HTTPOk
.build()
.content_type("text/plain")
.body("Welcome!").unwrap()
Ok(httpcodes::HTTPOk
.build()
.content_type("text/plain")
.body("Welcome!")?)
}
fn main() {
@ -37,10 +37,10 @@ fn main() {
.handler("/index.html", index)
// with path parameters
.resource("/", |r| r.handler(Method::GET, |req| {
Ok(httpcodes::HTTPFound
.build()
.header("LOCATION", "/index.html")
.body(Body::Empty)?)
httpcodes::HTTPFound
.build()
.header("LOCATION", "/index.html")
.body(Body::Empty)
})))
.serve_tls::<_, ()>("127.0.0.1:8080", pkcs12).unwrap();