1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 15:39:02 +02:00

Handlers done-ish.

This commit is contained in:
Cameron Dershem
2019-06-20 02:04:22 -04:00
parent 4291b822fc
commit 59f010461a
8 changed files with 62 additions and 79 deletions

View File

@ -1,7 +1,6 @@
// <main>
// <responder-trait>
use actix_web::{web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder};
use serde::Serialize;
use serde_json;
#[derive(Serialize)]
struct MyObj {
@ -23,9 +22,10 @@ impl Responder for MyObj {
}
}
fn index(_req: HttpRequest) -> impl Responder {
fn index() -> impl Responder {
MyObj { name: "user" }
}
// </responder-trait>
fn main() {
HttpServer::new(|| App::new().route("/", web::get().to(index)))
@ -34,4 +34,3 @@ fn main() {
.run()
.unwrap();
}
// </main>