diff options
| author | Fuwn <[email protected]> | 2023-03-31 17:49:21 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-03-31 17:49:21 -0700 |
| commit | 397ce63b0c28fbbe95b4019dd22a4a360e8a083f (patch) | |
| tree | 55aedcbfa0bef25168d8eae5f9c6f8f03f1379d5 /src/modules/router/module.rs | |
| parent | refactor(src): use response macros (diff) | |
| download | locus-397ce63b0c28fbbe95b4019dd22a4a360e8a083f.tar.xz locus-397ce63b0c28fbbe95b4019dd22a4a360e8a083f.zip | |
feat(translate): character set detection
Diffstat (limited to 'src/modules/router/module.rs')
| -rw-r--r-- | src/modules/router/module.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/modules/router/module.rs b/src/modules/router/module.rs index 1987568..dc9dae8 100644 --- a/src/modules/router/module.rs +++ b/src/modules/router/module.rs @@ -27,14 +27,28 @@ pub fn module(router: &mut windmark::Router) { super::ticker::module(&context); })); router.set_post_route_callback(Box::new({ - |context, content| { + |context, response| { info!( "closed connection from {} to {}", context.tcp.peer_addr().unwrap().ip(), context.url.to_string(), ); - super::translate::module(&context, content); + if let Some(language) = + windmark::utilities::queries_from_url(context.url).get("translate") + { + if super::translate::module(&context, response, language).is_err() { + response.content = format!( + "An error occurred during the translation process. Your language \ + might not be supported.\n\n=> {} View Original\n\n{}", + context + .url + .to_string() + .replace(&format!("translate={language}"), ""), + response.content + ); + } + } } })); } |