summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/main.go b/main.go
index f9ae240..37c0fdc 100644
--- a/main.go
+++ b/main.go
@@ -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)