aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index d810159..8e31fee 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,6 +4,7 @@ mod article;
mod atom;
mod blog;
mod error;
+mod i18n;
mod live;
mod poetry;
mod posts;
@@ -14,9 +15,12 @@ mod utils;
use std::{collections::HashSet, time::Duration};
+use i18n::set_language;
use poem::http::StatusCode;
use poem::i18n::unic_langid::langid;
-use poem::i18n::{I18NResources, Locale};
+use poem::i18n::I18NResources;
+use poem::session::{CookieConfig, CookieSession, ServerSession};
+use poem::web::cookie::{CookieKey, SameSite};
use poem::{
endpoint::EmbeddedFilesEndpoint,
get, handler,
@@ -36,6 +40,7 @@ use tracing_subscriber::FmtSubscriber;
use crate::article::Article;
use crate::blog::Blogpost;
+use crate::i18n::Locale;
use crate::poetry::Poem;
use crate::posts::Post;
@@ -208,6 +213,14 @@ async fn main() -> std::result::Result<(), std::io::Error> {
.build()
.unwrap();
+ let session = CookieSession::new(
+ // CookieConfig::private(CookieKey::generate())
+ // .name("blossom")
+ // .domain("blos.sm")
+ // .same_site(SameSite::Strict),
+ CookieConfig::default(),
+ );
+
let blossom = Route::new()
.at("/", get(home))
.at("/blog", get(get_blog))
@@ -220,7 +233,9 @@ async fn main() -> std::result::Result<(), std::io::Error> {
.nest("/static/", EmbeddedFilesEndpoint::<Static>::new())
.catch_all_error(custom_error)
.data(resources)
+ .around(set_language)
.with(Tracing)
+ .with(session)
.with(AddData::new(
reqwest::Client::builder()
.connect_timeout(Duration::from_secs(1))