Use handlebars to render index

[?]
Feb 17, 2021, 3:06 PM
65A3LIWUS7UNMIHACC7ED6SSSSGQMKW4SAHQLXMT2YT6PFJ7KVUQC

Dependencies

  • [2] OJO4B4QO Add login form and empty handler
  • [3] BCXEUKX6 Add config, static files and web server
  • [*] 4MZ4VIR7 Initial commit

Change contents

  • file addition: templates (dxwrx-rx-r)
    [5.6]
  • file move: index.html (-xw-x--x--)index.html (-xw-x--x--)
    [0.12]
    [3.5652]
  • edit in src/main.rs at line 2
    [3.24]
    [2.0]
    use actix_web::{middleware, web, App, HttpResponse, HttpServer};
  • replacement in src/main.rs at line 5
    [2.1][2.1:52]()
    use actix_web::{middleware, web, App, HttpServer};
    [2.1]
    [3.70]
    use handlebars::Handlebars;
  • edit in src/main.rs at line 12
    [2.94]
    [2.94]
    async fn index(hb: web::Data<Handlebars<'_>>) -> HttpResponse {
    let body = hb.render("index", &()).expect("render index");
    HttpResponse::Ok().body(body)
    }
  • edit in src/main.rs at line 40
    [3.780]
    [3.780]
    let mut handlebars = Handlebars::new();
    handlebars.set_strict_mode(true);
    handlebars
    .register_template_string("index", include_str!("templates/index.html"))
    .expect("index template");
    let handlebars_ref = web::Data::new(handlebars);
  • edit in src/main.rs at line 51
    [3.912]
    [2.151]
    .app_data(handlebars_ref.clone())
    .route("/", web::get().to(index))
    .route("/index.html", web::get().to(index))