From f1df8688b05b99747d2bcf3ec2f0bebbdd7e30b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20L=C3=B6ffert?= Date: Fri, 22 Nov 2019 18:11:40 +0100 Subject: [PATCH] strip base path --- cmd/neosproxy/main.go | 2 +- config/vo.go | 10 ++++++---- proxy/proxy.go | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/neosproxy/main.go b/cmd/neosproxy/main.go index d4ab4ad..542b300 100644 --- a/cmd/neosproxy/main.go +++ b/cmd/neosproxy/main.go @@ -5,12 +5,12 @@ import ( "path/filepath" "time" - "github.com/sirupsen/logrus" "github.com/foomo/neosproxy/cache/content/store/fs" "github.com/foomo/neosproxy/client/cms" "github.com/foomo/neosproxy/config" "github.com/foomo/neosproxy/logging" "github.com/foomo/neosproxy/proxy" + "github.com/sirupsen/logrus" ) func main() { diff --git a/config/vo.go b/config/vo.go index fb9840a..80f730d 100644 --- a/config/vo.go +++ b/config/vo.go @@ -17,8 +17,9 @@ type ObserverInterface interface { // Config struct definition type Config struct { Proxy struct { - Address string - Token string + Address string + Token string + BasePath string } Neos Neos Cache Cache @@ -77,8 +78,9 @@ type ObserverWebhook struct { type configFile struct { Proxy struct { - Address string - Token string + Address string + Token string + BasePath string } Neos struct { URL string `json:"url" yaml:"url"` diff --git a/proxy/proxy.go b/proxy/proxy.go index b28b8b7..f1fd049 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -4,7 +4,7 @@ import ( "crypto/subtle" "net/http" - "github.com/auth0/go-jwt-middleware" + jwtmiddleware "github.com/auth0/go-jwt-middleware" "github.com/foomo/neosproxy/logging" ) @@ -14,7 +14,8 @@ import ( // Run a proxy func (p *Proxy) Run() error { - return http.ListenAndServe(p.config.Proxy.Address, p.router) + handler := http.StripPrefix(p.config.Proxy.BasePath, p.router) + return http.ListenAndServe(p.config.Proxy.Address, handler) } //-----------------------------------------------------------------------------