summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/hosts.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/modules/hosts.rs b/src/modules/hosts.rs
index 6bd213a..20c6c85 100644
--- a/src/modules/hosts.rs
+++ b/src/modules/hosts.rs
@@ -30,10 +30,16 @@ impl Node for Hosts {
.headers()
.get(HOST)
.and_then(|e| e.to_str().ok())
- .map(remove_port)
- .ok_or(ServiceError::NoHost)?;
+ .map(remove_port);
- let node = self.0.get(host).ok_or(ServiceError::UnknownHost)?;
+ let node = match host {
+ Some(host) => self
+ .0
+ .get(host)
+ .or_else(|| self.0.get(":fallback"))
+ .ok_or(ServiceError::UnknownHost)?,
+ None => self.0.get(":none").ok_or(ServiceError::NoHost)?,
+ };
node.handle(context, request).await
})