MSP-2684 Update Entrypoint function
This commit is contained in:
1 parent
87690bbd12
commit
1f40e9d5d3
2 files changed
+5
-9
No files matched your search
@@ -10,13 +10,13 @@ import (
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, pathPrefix *string) http.Handler {
|
||||
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, pathPrefix string, withPrefix bool) http.Handler {
|
||||
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
||||
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
|
||||
|
||||
endpoint := req.URL.Path
|
||||
if pathPrefix != nil {
|
||||
prefix := fmt.Sprintf("%s/", *pathPrefix)
|
||||
if !withPrefix {
|
||||
prefix := fmt.Sprintf("%s/", pathPrefix)
|
||||
endpoint = strings.TrimPrefix(req.URL.Path, prefix)
|
||||
}
|
||||
ctx := request.NewContext(req, writer, endpoint)
|
||||
|
||||
Reference in new issue
Block a user