|
|
|
@ -30,24 +30,6 @@ func serveHTTPS(w http.ResponseWriter, r *http.Request) (int, int64, string) {
@@ -30,24 +30,6 @@ func serveHTTPS(w http.ResponseWriter, r *http.Request) (int, int64, string) {
|
|
|
|
|
status := http.StatusTemporaryRedirect |
|
|
|
|
http.Redirect(w, r, u.String(), status) |
|
|
|
|
return status, -1, "" |
|
|
|
|
} else if r.URL.Path == "/assets/style.css" { |
|
|
|
|
status := http.StatusOK |
|
|
|
|
w.Header().Set("Content-Type", cssType) |
|
|
|
|
w.WriteHeader(status) |
|
|
|
|
|
|
|
|
|
if r.Method == "HEAD" { |
|
|
|
|
return status, 0, "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Do we have a custom CSS file? If so, we use this instead.
|
|
|
|
|
if css, found := customCSS[r.URL.Hostname()]; found { |
|
|
|
|
w.Write(css) |
|
|
|
|
return status, int64(len(css)), "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Default CSS
|
|
|
|
|
w.Write(cssBytes) |
|
|
|
|
return status, int64(len(cssBytes)), "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pathBytes := []byte(r.URL.Path) |
|
|
|
@ -57,6 +39,23 @@ func serveHTTPS(w http.ResponseWriter, r *http.Request) (int, int64, string) {
@@ -57,6 +39,23 @@ func serveHTTPS(w http.ResponseWriter, r *http.Request) (int, int64, string) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if host, ok := config.Hosts[r.URL.Hostname()]; ok { |
|
|
|
|
if strings.HasSuffix(r.URL.Path, "/assets/style.css") { |
|
|
|
|
status := http.StatusOK |
|
|
|
|
w.Header().Set("Content-Type", cssType) |
|
|
|
|
w.WriteHeader(status) |
|
|
|
|
|
|
|
|
|
if r.Method == "HEAD" { |
|
|
|
|
return status, 0, "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if host.css != nil { |
|
|
|
|
w.Write(host.css) |
|
|
|
|
} else { |
|
|
|
|
w.Write(cssBytes) |
|
|
|
|
} |
|
|
|
|
return status, int64(len(cssBytes)), "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, serve := range host.Paths { |
|
|
|
|
matchedRegexp := serve.r != nil && serve.r.Match(pathBytes) |
|
|
|
|
matchedPrefix := serve.r == nil && strings.HasPrefix(r.URL.Path, serve.Path) |
|
|
|
|