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,12 +1,13 @@
|
||||
[package]
|
||||
name = "template-askama"
|
||||
version = "0.1.0"
|
||||
version = "2.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0.0"
|
||||
actix-web = "2.0.0-alpha.3"
|
||||
actix-rt = "1.0.0-alpha.3"
|
||||
env_logger = "0.6"
|
||||
askama = "0.8"
|
||||
|
||||
|
@ -14,7 +14,7 @@ struct UserTemplate<'a> {
|
||||
#[template(path = "index.html")]
|
||||
struct Index;
|
||||
|
||||
fn index(query: web::Query<HashMap<String, String>>) -> Result<HttpResponse> {
|
||||
async fn index(query: web::Query<HashMap<String, String>>) -> Result<HttpResponse> {
|
||||
let s = if let Some(name) = query.get("name") {
|
||||
UserTemplate {
|
||||
name,
|
||||
@ -28,11 +28,13 @@ fn index(query: web::Query<HashMap<String, String>>) -> Result<HttpResponse> {
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(s))
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
// start http server
|
||||
HttpServer::new(move || {
|
||||
App::new().service(web::resource("/").route(web::get().to(index)))
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
|
Reference in New Issue
Block a user