]> Sergey Matveev's repositories - godlighty.git/blobdiff - handler.go
FastCGI running example
[godlighty.git] / handler.go
index 8953a8060713f04cb3dbdd14df575afcb9ff5a02..6fa1d35bbeb0e1a6290900f55ecaaf9a8b91f998 100644 (file)
@@ -24,6 +24,7 @@ import (
        "fmt"
        "io/ioutil"
        "log"
+       "net"
        "net/http"
        "net/url"
        "os"
@@ -313,6 +314,9 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
                http.Error(w, "invalid URL path", http.StatusBadRequest)
                return
        }
-       host := strings.SplitN(r.Host, ":", 2)[0]
+       host, _, err := net.SplitHostPort(r.Host)
+       if err != nil {
+               host = r.Host
+       }
        h.Handle(w, r, host, Hosts[host])
 }