diff --git a/examples/front-page/flexible-responders/Cargo.toml b/examples/front-page/flexible-responders/Cargo.toml
index ed8f468..ec19e5d 100644
--- a/examples/front-page/flexible-responders/Cargo.toml
+++ b/examples/front-page/flexible-responders/Cargo.toml
@@ -4,3 +4,5 @@ version = "0.1.0"
edition = "2018"
[dependencies]
+actix-web = "1.0"
+serde = "1.0"
diff --git a/examples/front-page/flexible-responders/src/main.rs b/examples/front-page/flexible-responders/src/main.rs
index 6846fcf..4d23898 100644
--- a/examples/front-page/flexible-responders/src/main.rs
+++ b/examples/front-page/flexible-responders/src/main.rs
@@ -1,5 +1,29 @@
+use actix_web::{web, App, HttpRequest, HttpServer, Responder};
+use serde::Serialize;
+
//
+#[derive(Serialize)]
+struct Measurement {
+ temperature: f32,
+}
+
+fn hello_world() -> impl Responder {
+ "Hello World!"
+}
+
+fn current_temperature(_req: HttpRequest) -> impl Responder {
+ web::Json(Measurement { temperature: 42.3 })
+}
+
fn main() {
- println!("Hello, world!");
+ HttpServer::new(|| {
+ App::new()
+ .service(web::resource("/").to(hello_world))
+ .service(web::resource("/temp").to(current_temperature))
+ })
+ .bind("127.0.0.1:8000")
+ .expect("Can not bind to port 8000")
+ .run()
+ .unwrap();
}
//
diff --git a/examples/front-page/powerful-extractors/static/form.html b/examples/front-page/powerful-extractors/static/form.html
index d482c8c..6fc8da4 100644
--- a/examples/front-page/powerful-extractors/static/form.html
+++ b/examples/front-page/powerful-extractors/static/form.html
@@ -11,6 +11,12 @@
diff --git a/layouts/index.html b/layouts/index.html
index b85074d..8ae3988 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -79,7 +79,7 @@ fn hello_world() -> impl Responder {
}
fn current_temperature(_req: HttpRequest) -> impl Responder {
- Json(Measurement { temperature: 42.3 })
+ web::Json(Measurement { temperature: 42.3 })
}` "rust" "" }}