summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormrw1593 <botahamec@outlook.com>2023-05-15 21:42:47 -0400
committermrw1593 <botahamec@outlook.com>2023-05-29 10:46:04 -0400
commite38854c7db0fe6f006304d7f638b6aa190fc2d87 (patch)
treeeb730768a5f9c68f20c3b20a180cb1ab327a2de5 /src/main.rs
parent3f0cfb69f2ab1dda4425fe871a6cbf3b4bfb8dc3 (diff)
Started on frontend
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 7d2b643..7b25dd1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,5 @@
use actix_web::http::header::{self, HeaderValue};
-use actix_web::middleware::{DefaultHeaders, ErrorHandlerResponse, ErrorHandlers, Logger};
+use actix_web::middleware::{ErrorHandlerResponse, ErrorHandlers, Logger, NormalizePath};
use actix_web::web::Data;
use actix_web::{dev, App, HttpServer};
@@ -7,8 +7,10 @@ use exun::*;
mod api;
mod models;
+mod resources;
mod services;
+use resources::*;
use services::*;
fn error_content_language<B>(
@@ -31,12 +33,27 @@ async fn main() -> Result<(), RawUnexpected> {
let db_url = secrets::database_url()?;
let sql_pool = db::initialize(&db_url).await?;
+ let tera = templates::initialize()?;
+
+ let translations = languages::initialize()?;
+
// start the server
HttpServer::new(move || {
App::new()
+ // middleware
.wrap(ErrorHandlers::new().default_handler(error_content_language))
+ .wrap(NormalizePath::trim())
.wrap(Logger::new("\"%r\" %s %Dms"))
+ // app shared state
.app_data(Data::new(sql_pool.clone()))
+ .app_data(Data::new(tera.clone()))
+ .app_data(Data::new(translations.clone()))
+ // frontend services
+ // has to be first so they don't get overwritten by the "" scope
+ .service(style::get_css)
+ .service(scripts::get_js)
+ .service(languages::languages())
+ // api services
.service(api::liveops())
.service(api::users())
.service(api::ops())