Skip to content

Commit

Permalink
rest server: update root middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
agungdwiprasetyo committed Mar 14, 2023
1 parent be3e2cb commit 719cf20
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion codebase/app/rest_server/rest_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ func NewServer(service factory.ServiceFactory, opts ...OptionFunc) factory.AppSe
}

server.serverEngine.HTTPErrorHandler = server.opt.errorHandler
server.serverEngine.Use(server.opt.rootMiddlewares...)

server.serverEngine.GET("/", echo.WrapHandler(server.opt.rootHandler))
server.serverEngine.GET("/memstats",
echo.WrapHandler(http.HandlerFunc(candishared.HTTPMemstatsHandler)),
echo.WrapMiddleware(service.GetDependency().GetMiddleware().HTTPBasicAuth),
)

restRootPath := server.serverEngine.Group(server.opt.rootPath, server.opt.rootMiddlewares...)
restRootPath := server.serverEngine.Group(server.opt.rootPath)
for _, m := range service.GetModules() {
if h := m.RESTHandler(); h != nil {
h.Mount(restRootPath)
Expand Down
2 changes: 1 addition & 1 deletion init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package candi

const (
// Version of this library
Version = "v1.14.1"
Version = "v1.14.2"
)
2 changes: 1 addition & 1 deletion wrapper/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func HTTPMiddlewareTracer(maxLogSize int) func(http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {

isDisableTrace, _ := strconv.ParseBool(req.Header.Get(candihelper.HeaderDisableTrace))
if isDisableTrace {
if isDisableTrace || req.URL.Path == "/" {
next.ServeHTTP(rw, req.WithContext(tracer.SkipTraceContext(req.Context())))
return
}
Expand Down

0 comments on commit 719cf20

Please sign in to comment.