Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use web prefix for main API #234

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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