summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-15 13:01:25 -0500
committersanine-a <sanine.not@pm.me>2023-05-15 13:01:25 -0500
commit8b47f868ce97f50757225a72b958ed483336fd0c (patch)
tree992e736787868e599fe06267aebbbd9d968e8b37 /main.go
parent9db22ca2f86f41f98baa23a8e53d69c22ece2a67 (diff)
add ability to serve under subdirectory
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.go b/main.go
index b61e237..6e37f43 100644
--- a/main.go
+++ b/main.go
@@ -25,21 +25,21 @@ func main() {
users := getUsers(conf)
// add phlox endpoints
- http.HandleFunc("/phlox/login", func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(conf.PathPrefix + "/phlox/login", func(w http.ResponseWriter, r *http.Request) {
Login(w, r, users, sessions, pages)
})
- http.HandleFunc("/phlox/logout", func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(conf.PathPrefix + "/phlox/logout", func(w http.ResponseWriter, r *http.Request) {
Logout(w, r, sessions)
})
- http.HandleFunc("/phlox/asset/", func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(conf.PathPrefix + "/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) {
+ http.HandleFunc(conf.PathPrefix + "/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
w.Header().Add("Location", "/phlox/login")
w.WriteHeader(http.StatusTemporaryRedirect)
@@ -50,7 +50,7 @@ func main() {
// add reverse proxy endpoints
for _, e := range conf.Endpoints {
- addEndpoint(sessions, pages, e)
+ addEndpoint(conf, sessions, pages, e)
}
// timer for inactivity log out