summaryrefslogtreecommitdiff
path: root/proxy.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 /proxy.go
parent9db22ca2f86f41f98baa23a8e53d69c22ece2a67 (diff)
add ability to serve under subdirectory
Diffstat (limited to 'proxy.go')
-rw-r--r--proxy.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/proxy.go b/proxy.go
index 4442fb9..50260f2 100644
--- a/proxy.go
+++ b/proxy.go
@@ -19,7 +19,7 @@ type Endpoint struct {
}
-func addEndpoint(s *auth.Sessions, pages page.Pages, e config.Endpoint) {
+func addEndpoint(conf config.Config, s *auth.Sessions, pages page.Pages, e config.Endpoint) {
log.Infof("proxying endpoint %v to %v", e.Path, e.Address)
origin, err := url.Parse(e.Address)
if err != nil {
@@ -31,12 +31,12 @@ func addEndpoint(s *auth.Sessions, pages page.Pages, e config.Endpoint) {
Origin: origin,
}
- http.HandleFunc(e.Path, func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(conf.PathPrefix + e.Path, func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Location", e.Path + "/")
w.WriteHeader(http.StatusPermanentRedirect)
})
- http.HandleFunc(e.Path + "/", func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(conf.PathPrefix + e.Path + "/", func(w http.ResponseWriter, r *http.Request) {
log.Infof("REQ: %v", r.URL.Path)
proxy(w, r, s, pages, end)
})