Nick Thomas: 2
Change how the default value for config.server[].index is handled
Change how the default value for config.server[].index is handled
4 files changed, 22 insertions(+), 18 deletions(-)
The `handle_connection` function is long and scary; this is an easy
thing to remove from it, essentially turning code into data.
---
src/con_handler.rs | 5 -----src/config.rs | 6 ++++++
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/con_handler.rs b/src/con_handler.rs
index 6d6c83f..eff7259 100644
--- a/src/con_handler.rs+++ b/src/con_handler.rs
@@ -155,11 +155,6 @@ async fn handle_cgi(
// TODO Rewrite this monster.
pub async fn handle_connection(mut con: conn::Connection, url: url::Url) -> Result {
- let index = match &con.srv.server.index {- Some(i) => i.clone(),- None => "index.gemini".to_string(),- };- match &con.srv.server.redirect.to_owned() {
Some(re) => {
let u = match url.path() {
diff --git a/src/config.rs b/src/config.rs
index 0f83cf3..b888d08 100644
--- a/src/config.rs+++ b/src/config.rs
@@ -73,6 +73,12 @@ impl Config {
Err(e) => return Err(Box::new(e)),
};
+ for srv in config.server.iter_mut() {+ if srv.index.is_none() {+ srv.index = Some("index.gemini".to_owned());+ }+ }+ if config.host.is_some() || config.port.is_some() {
eprintln!(
"The host/port keys are depricated in favor \
--
2.39.2
[PATCH v2] Change how the default value for config.server[].index is handled
Export this patch