summaryrefslogtreecommitdiff
path: root/proxy.go
diff options
context:
space:
mode:
Diffstat (limited to 'proxy.go')
-rw-r--r--proxy.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/proxy.go b/proxy.go
index 50260f2..d5bfc88 100644
--- a/proxy.go
+++ b/proxy.go
@@ -19,7 +19,7 @@ type Endpoint struct {
}
-func addEndpoint(conf config.Config, s *auth.Sessions, pages page.Pages, e config.Endpoint) {
+func addEndpoint(conf config.Config, api config.Api, 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,22 +31,22 @@ func addEndpoint(conf config.Config, s *auth.Sessions, pages page.Pages, e confi
Origin: origin,
}
- http.HandleFunc(conf.PathPrefix + e.Path, func(w http.ResponseWriter, r *http.Request) {
- w.Header().Add("Location", e.Path + "/")
+ http.HandleFunc(e.Path, func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Add("Location", api.Prefix + e.Path + "/")
w.WriteHeader(http.StatusPermanentRedirect)
})
- http.HandleFunc(conf.PathPrefix + e.Path + "/", func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(e.Path + "/", func(w http.ResponseWriter, r *http.Request) {
log.Infof("REQ: %v", r.URL.Path)
- proxy(w, r, s, pages, end)
+ proxy(w, r, api, s, pages, end)
})
}
-func proxy(w http.ResponseWriter, r *http.Request, s *auth.Sessions, pages page.Pages, end Endpoint) {
+func proxy(w http.ResponseWriter, r *http.Request, api config.Api, s *auth.Sessions, pages page.Pages, end Endpoint) {
ok := authenticateRequest(r, s)
if !ok {
- w.Header().Set("Location", "/phlox/login")
+ w.Header().Set("Location", api.Prefix + api.Login)
w.WriteHeader(http.StatusTemporaryRedirect)
return
}