standalone binary
embed the sqlite3 library aswell as all the templates.
This commit is contained in:
+2
-1
@@ -301,7 +301,8 @@ fn create_admin(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
fn apply_migrations(config: &ServerConfig) -> Result<(), ServerError> {
|
||||
slog_info!(
|
||||
config.log,
|
||||
"Creating a database file and running the migrations:"
|
||||
"Creating a database file and running the migrations in the file {}:",
|
||||
&config.db.display()
|
||||
);
|
||||
let connection = queries::establish_connection(&config.db)?;
|
||||
crate::embedded_migrations::run_with_output(&connection, &mut std::io::stdout())?;
|
||||
|
||||
+43
-1
@@ -186,6 +186,48 @@ impl ServerConfig {
|
||||
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
|
||||
embed_migrations!("migrations/");
|
||||
|
||||
fn build_tera() -> Tera {
|
||||
let mut tera = Tera::default();
|
||||
|
||||
tera.add_raw_templates(vec![
|
||||
("admin.html", include_str!("../templates/admin.html")),
|
||||
("base.html", include_str!("../templates/base.html")),
|
||||
(
|
||||
"edit_link.html",
|
||||
include_str!("../templates/edit_link.html"),
|
||||
),
|
||||
(
|
||||
"edit_profile.html",
|
||||
include_str!("../templates/edit_profile.html"),
|
||||
),
|
||||
(
|
||||
"index_users.html",
|
||||
include_str!("../templates/index_users.html"),
|
||||
),
|
||||
("index.html", include_str!("../templates/index.html")),
|
||||
("login.html", include_str!("../templates/login.html")),
|
||||
(
|
||||
"not_found.html",
|
||||
include_str!("../templates/not_found.html"),
|
||||
),
|
||||
("signup.html", include_str!("../templates/signup.html")),
|
||||
(
|
||||
"submission.html",
|
||||
include_str!("../templates/submission.html"),
|
||||
),
|
||||
(
|
||||
"view_link.html",
|
||||
include_str!("../templates/view_link.html"),
|
||||
),
|
||||
(
|
||||
"view_profile.html",
|
||||
include_str!("../templates/view_profile.html"),
|
||||
),
|
||||
])
|
||||
.expect("failed to parse templates");
|
||||
tera
|
||||
}
|
||||
|
||||
#[allow(clippy::future_not_send)]
|
||||
async fn webservice(server_config: ServerConfig) -> std::io::Result<()> {
|
||||
let host_port = format!("{}:{}", &server_config.internal_ip, &server_config.port);
|
||||
@@ -198,7 +240,7 @@ async fn webservice(server_config: ServerConfig) -> std::io::Result<()> {
|
||||
);
|
||||
|
||||
HttpServer::new(move || {
|
||||
let tera = Tera::new("templates/**/*").expect("failed to initialize the templates");
|
||||
let tera = build_tera(); //Tera::new("templates/**/*").expect("failed to initialize the templates");
|
||||
let generated = generate();
|
||||
App::new()
|
||||
.data(server_config.clone())
|
||||
|
||||
Reference in New Issue
Block a user