Skip to content

Commit

Permalink
Use web prefix for main API
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouzhuojie committed Mar 9, 2019
1 parent 65fd5b9 commit 88c5da0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser/flagr-ui/config/prod.env.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
NODE_ENV: '"production"',
API_URL: '"/api/v1"',
API_URL: '"api/v1"',

// ',' separated string
// For example
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ var Config = struct {
// "HS256" and "RS256" supported
JWTAuthSigningMethod string `env:"FLAGR_JWT_AUTH_SIGNING_METHOD" envDefault:"HS256"`

// WebPrefix - base path for web
// WebPrefix - base path for web and API
// e.g. FLAGR_WEB_PREFIX=/foo
// UI path => localhost:18000/foo"
// API path => localhost:18000/foo/api/v1"
WebPrefix string `env:"FLAGR_WEB_PREFIX" envDefault:""`
}{}
4 changes: 4 additions & 0 deletions pkg/config/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func SetupGlobalMiddleware(handler http.Handler) http.Handler {

n.Use(setupRecoveryMiddleware())

if Config.WebPrefix != "" {
handler = http.StripPrefix(Config.WebPrefix, handler)
}

if Config.PProfEnabled {
n.UseHandler(pprof.New()(handler))
} else {
Expand Down

0 comments on commit 88c5da0

Please sign in to comment.