From 7ef45a39f92db203a5e95f7a127151182155013d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Fri, 2 Nov 2018 15:30:12 +1100 Subject: [PATCH] default to serve host content instead of 404 --- http.go | 3 +-- main.go | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/http.go b/http.go index 3b9614a..6dd515b 100644 --- a/http.go +++ b/http.go @@ -54,8 +54,7 @@ func hostByIP(w http.ResponseWriter, r *http.Request) (*clustersconfig.Host, *cl remoteAddr := r.RemoteAddr if *trustXFF { - xff := r.Header.Get("X-Forwarded-For") - if xff != "" { + if xff := r.Header.Get("X-Forwarded-For"); xff != "" { remoteAddr = strings.Split(xff, ",")[0] } } diff --git a/main.go b/main.go index 782bbfd..5b419d6 100644 --- a/main.go +++ b/main.go @@ -33,11 +33,8 @@ func main() { go casCleaner() - http.HandleFunc("/ipxe", serveHostByIP) - http.HandleFunc("/kernel", serveHostByIP) - http.HandleFunc("/initrd", serveHostByIP) - http.HandleFunc("/boot.iso", serveHostByIP) - http.HandleFunc("/static-pods", serveHostByIP) + // by default, serve a host resource by its IP + http.HandleFunc("/", serveHostByIP) http.HandleFunc("/hosts", serveHosts) http.HandleFunc("/hosts/", serveHost)