mirror of
https://github.com/actix/examples
synced 2025-06-28 18:00:37 +02:00
upgrade to 2.0 alpha.3
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
[package]
|
||||
name = "template_handlebars"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
authors = ["Alexandru Tiniuc <tiniuc.alexandru@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0"
|
||||
actix-web = "2.0.0-alpha.3"
|
||||
actix-rt = "1.0.0-alpha.3"
|
||||
handlebars = "2.0.0-beta.2"
|
||||
serde_json = "1.0"
|
@ -13,7 +13,7 @@ use std::io;
|
||||
|
||||
// Macro documentation can be found in the actix_web_codegen crate
|
||||
#[get("/")]
|
||||
fn index(hb: web::Data<Handlebars>) -> HttpResponse {
|
||||
async fn index(hb: web::Data<Handlebars>) -> HttpResponse {
|
||||
let data = json!({
|
||||
"name": "Handlebars"
|
||||
});
|
||||
@ -23,7 +23,10 @@ fn index(hb: web::Data<Handlebars>) -> HttpResponse {
|
||||
}
|
||||
|
||||
#[get("/{user}/{data}")]
|
||||
fn user(hb: web::Data<Handlebars>, info: web::Path<(String, String)>) -> HttpResponse {
|
||||
async fn user(
|
||||
hb: web::Data<Handlebars>,
|
||||
info: web::Path<(String, String)>,
|
||||
) -> HttpResponse {
|
||||
let data = json!({
|
||||
"user": info.0,
|
||||
"data": info.1
|
||||
@ -33,7 +36,8 @@ fn user(hb: web::Data<Handlebars>, info: web::Path<(String, String)>) -> HttpRes
|
||||
HttpResponse::Ok().body(body)
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
// Handlebars uses a repository for the compiled templates. This object must be
|
||||
// shared between the application threads, and is therefore passed to the
|
||||
// Application Builder as an atomic reference-counted pointer.
|
||||
@ -50,5 +54,6 @@ fn main() -> io::Result<()> {
|
||||
.service(user)
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
|
Reference in New Issue
Block a user