use rustclamp::web::{self, package_view};
pub const NAME: &str = "__NAME__";
pub struct __STRUCT__ {
title: String,
}
impl From<&rustclamp::config::Config> for __STRUCT__ {
fn from(config: &rustclamp::config::Config) -> Self {
Self {
title: config.get("__ENV___TITLE").unwrap_or(NAME).to_owned(),
}
}
}
impl web::Package for __STRUCT__ {
fn routes(self, router: web::Router) -> web::Router {
let title = self.title;
router
.get("/__NAME__", move |_| {
package_view(
NAME,
"index",
include_str!("../resources/views/index.html"),
&[("title", &title)],
)
})
.get("/__NAME__/__NAME__.css", |_| {
web::Response::new(200, "text/css", include_str!("../resources/css/__NAME__.css"))
})
}
}