Add lang option
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gemserv"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
authors = ["int 80h <int@80h.dev>"]
|
||||
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.
|
||||
|
||||
- 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
|
||||
- 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
|
||||
# ending in gemini or gmi.
|
||||
index = "index.gmi"
|
||||
# lang is optional
|
||||
lang = "en"
|
||||
# cgi is optional bool
|
||||
cgi = true
|
||||
# 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 cert: String,
|
||||
pub index: Option<String>,
|
||||
pub lang: Option<String>,
|
||||
#[cfg(feature = "cgi")]
|
||||
pub cgi: Option<bool>,
|
||||
#[cfg(feature = "cgi")]
|
||||
|
||||
@@ -296,7 +296,10 @@ async fn handle_connection(
|
||||
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/") {
|
||||
logger::logger(con.peer_addr, Status::Success, &request);
|
||||
get_binary(con, path, mime).await?;
|
||||
|
||||
Reference in New Issue
Block a user