Skip to content

Commit

Permalink
fix: basePath
Browse files Browse the repository at this point in the history
Signed-off-by: MicroOps-cn <[email protected]>
  • Loading branch information
MicroOps-cn committed Feb 8, 2025
1 parent 625ba9f commit 50fdd63
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/idas/cmd/idas.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func Run(ctx context.Context, logger kitlog.Logger, stopCh *signals.Handler) (er
httpLoginURL.Path = path.Join(httpLoginURL.Path, webPrefix, "account/login")
ctx = context.WithValue(ctx, global.HTTPLoginURLKey, httpLoginURL.String())
ctx = context.WithValue(ctx, global.HTTPExternalURLKey, httpExternalURL.String())
ctx = context.WithValue(ctx, global.HTTPWebPrefixKey, w.M(url.JoinPath(HTTPBase, webPrefix)))
ctx = context.WithValue(ctx, global.HTTPWebPrefixKey, webPrefix)
ctx = context.WithValue(ctx, global.HTTPWebBasePath, HTTPBase)
level.Info(logger).Log("msg", "Start service", "externalUrl", httpExternalURL, "webPrefix", w.M(url.JoinPath(HTTPBase, webPrefix)), "loginUrl", httpLoginURL)
var (
svc = service.New(ctx)
Expand Down
1 change: 1 addition & 0 deletions pkg/global/define.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ const (
HTTPExternalURLKey = "__http_external_url__"
HTTPLoginURLKey = "__http_login_url__"
HTTPWebPrefixKey = "__http_web_prefix__"
HTTPWebBasePath = "__http_web_base_path__"
RedisKeyPrefix = "IDAS"
)
3 changes: 2 additions & 1 deletion pkg/transport/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ func NewHTTPHandler(ctx context.Context, logger log.Logger, endpoints endpoint.S
m.Add(restfulspec.NewOpenAPIService(specConf))
}
webPrefix := ctx.Value(global.HTTPWebPrefixKey).(string)
m.Handle(webPrefix, http.StripPrefix(webPrefix, NewStaticFileServer(ctx, w.M[fs.FS](fs.Sub(staticFs, "static")))))
webBasePath := ctx.Value(global.HTTPWebBasePath).(string)
m.Handle(http2.JoinPath(webPrefix, webBasePath), http.StripPrefix(http2.JoinPath(webPrefix, webBasePath), NewStaticFileServer(ctx, w.M[fs.FS](fs.Sub(staticFs, "static")))))
m.Handle("/healthz", http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
writer.Write([]byte("ok\n"))
}))
Expand Down

0 comments on commit 50fdd63

Please sign in to comment.