static pages are rendered and cached

This commit is contained in:
realaravinth
2021-05-04 15:45:53 +05:30
parent f817f49182
commit fe02c43c2c
7 changed files with 49 additions and 65 deletions

View File

@@ -16,29 +16,27 @@
*/
use actix_web::{HttpResponse, Responder};
use lazy_static::lazy_static;
use sailfish::TemplateOnce;
use crate::pages::TITLE;
#[derive(Clone, TemplateOnce)]
#[template(path = "auth/login/index.html")]
struct IndexPage<'a> {
name: &'a str,
title: &'a str,
}
struct IndexPage;
impl<'a> Default for IndexPage<'a> {
const PAGE: &str = "Login";
impl Default for IndexPage {
fn default() -> Self {
IndexPage {
name: TITLE,
title: "Login",
}
IndexPage
}
}
lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
}
pub async fn login() -> impl Responder {
let body = IndexPage::default().render_once().unwrap();
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(body)
.body(&*INDEX)
}

View File

@@ -16,29 +16,27 @@
*/
use actix_web::{HttpResponse, Responder};
use lazy_static::lazy_static;
use sailfish::TemplateOnce;
use crate::pages::TITLE;
#[derive(TemplateOnce, Clone)]
#[derive(Clone, TemplateOnce)]
#[template(path = "auth/register/index.html")]
struct IndexPage<'a> {
name: &'a str,
title: &'a str,
}
struct IndexPage;
impl<'a> Default for IndexPage<'a> {
const PAGE: &str = "Join";
impl Default for IndexPage {
fn default() -> Self {
IndexPage {
name: TITLE,
title: "Join",
}
IndexPage
}
}
lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
}
pub async fn join() -> impl Responder {
let body = IndexPage::default().render_once().unwrap();
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(body)
.body(&*INDEX)
}