Add lang option
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gemserv"
|
name = "gemserv"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
authors = ["int 80h <int@80h.dev>"]
|
authors = ["int 80h <int@80h.dev>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
3
README
3
README
@@ -16,7 +16,8 @@ A gemini server written in rust.
|
|||||||
OpenSSL 1.1.0g or LibreSSL 2.7.0 or newer is required.
|
OpenSSL 1.1.0g or LibreSSL 2.7.0 or newer is required.
|
||||||
|
|
||||||
- Clone the repo
|
- Clone the repo
|
||||||
- Run 'cargo build --release'
|
- If you want to use all features run 'cargo build --release' or if you only
|
||||||
|
want to serve static files run 'cargo build --release --no-default-features'
|
||||||
- Modify the config.toml to your needs
|
- Modify the config.toml to your needs
|
||||||
- Run './target/release/gemserv config.toml'
|
- Run './target/release/gemserv config.toml'
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ cert = "/path/to/cert"
|
|||||||
# index is optional but defaults to index.gemini. The server will serve files
|
# index is optional but defaults to index.gemini. The server will serve files
|
||||||
# ending in gemini or gmi.
|
# ending in gemini or gmi.
|
||||||
index = "index.gmi"
|
index = "index.gmi"
|
||||||
|
# lang is optional
|
||||||
|
lang = "en"
|
||||||
# cgi is optional bool
|
# cgi is optional bool
|
||||||
cgi = true
|
cgi = true
|
||||||
# cgipath is optional and only checked if cgi is true. It restricts cgi to only
|
# cgipath is optional and only checked if cgi is true. It restricts cgi to only
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ pub struct Server {
|
|||||||
pub key: String,
|
pub key: String,
|
||||||
pub cert: String,
|
pub cert: String,
|
||||||
pub index: Option<String>,
|
pub index: Option<String>,
|
||||||
|
pub lang: Option<String>,
|
||||||
#[cfg(feature = "cgi")]
|
#[cfg(feature = "cgi")]
|
||||||
pub cgi: Option<bool>,
|
pub cgi: Option<bool>,
|
||||||
#[cfg(feature = "cgi")]
|
#[cfg(feature = "cgi")]
|
||||||
|
|||||||
@@ -296,7 +296,10 @@ async fn handle_connection(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mime = get_mime(&path);
|
let mut mime = get_mime(&path);
|
||||||
|
if mime == "text/gemini" && srv.server.lang.is_some() {
|
||||||
|
mime += &("; lang=".to_string() + &srv.server.lang.to_owned().unwrap());
|
||||||
|
}
|
||||||
if !mime.starts_with("text/") {
|
if !mime.starts_with("text/") {
|
||||||
logger::logger(con.peer_addr, Status::Success, &request);
|
logger::logger(con.peer_addr, Status::Success, &request);
|
||||||
get_binary(con, path, mime).await?;
|
get_binary(con, path, mime).await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user