MSP-2684 Add using 'withPrefix' flag to avoid trimming request's url prefix
This commit is contained in:
1 parent
402c6c18cf
commit
8a83ba0b3a
2 files changed
+11
-5
No files matched your search
@@ -10,12 +10,15 @@ import (
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
func Entrypoint(maxReqBodySize int64, next Handler, pathPrefix string, logger log.Logger) http.Handler {
|
||||
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, pathPrefix *string) http.Handler {
|
||||
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
||||
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
|
||||
|
||||
prefix := fmt.Sprintf("%s/", pathPrefix)
|
||||
endpoint := strings.TrimPrefix(req.URL.Path, prefix)
|
||||
endpoint := req.URL.Path
|
||||
if pathPrefix != nil {
|
||||
prefix := fmt.Sprintf("%s/", *pathPrefix)
|
||||
endpoint = strings.TrimPrefix(req.URL.Path, prefix)
|
||||
}
|
||||
ctx := request.NewContext(req, writer, endpoint)
|
||||
|
||||
err := next.Handle(ctx)
|
||||
|
||||
Reference in new issue
Block a user