diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -5,6 +5,8 @@ import ( "fmt" "flag" "errors" + "strings" + "path/filepath" "net/http" "encoding/json" "sanine.net/git/phlox/config" @@ -30,6 +32,21 @@ func main() { Logout(w, r, sessions) }) + http.HandleFunc("/phlox/asset/", func(w http.ResponseWriter, r *http.Request) { + filename := strings.TrimPrefix(r.URL.Path, "/phlox/asset/") + path := filepath.Join(conf.AssetDirectory, filename) + http.ServeFile(w, r, path) + }) + + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/" { + w.Header().Add("Location", "/phlox/login") + w.WriteHeader(http.StatusTemporaryRedirect) + } else { + pages.ServeError404(w) + } + }) + // add reverse proxy endpoints for _, e := range conf.Endpoints { addEndpoint(sessions, pages, e) |