add feature to specify default backend

This commit is contained in:
Jun Kurihara 2022-06-28 11:51:38 -04:00
commit 3491b80142
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
9 changed files with 50 additions and 12 deletions

View file

@ -39,8 +39,11 @@ where
} else {
return http_error(StatusCode::SERVICE_UNAVAILABLE);
};
let backend = if let Some(be) = self.backends.get(server_name.as_str()) {
let backend = if let Some(be) = self.backends.apps.get(server_name.as_str()) {
be
} else if let Some(default_be) = &self.backends.default_app {
debug!("Serving by default app: {}", default_be);
self.backends.apps.get(default_be).unwrap()
} else {
return http_error(StatusCode::SERVICE_UNAVAILABLE);
};