From b8b96474a09881fedbcd9ae30ed3246314161324 Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Mon, 5 Jun 2023 23:34:50 +0300 Subject: [PATCH] fix #2147 --- core/router/handler.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/core/router/handler.go b/core/router/handler.go index 87eaf9db..34c44931 100644 --- a/core/router/handler.go +++ b/core/router/handler.go @@ -65,12 +65,28 @@ var _ HTTPErrorHandler = (*routerHandler)(nil) // NewDefaultHandler returns the handler which is responsible // to map the request with a route (aka mux implementation). func NewDefaultHandler(config context.ConfigurationReadOnly, logger *golog.Logger) RequestHandler { + var ( + disablePathCorrection bool + disablePathCorrectionRedirection bool + fireMethodNotAllowed bool + enablePathIntelligence bool + forceLowercaseRouting bool + ) + + if config != nil { // #2147 + disablePathCorrection = config.GetDisablePathCorrection() + disablePathCorrectionRedirection = config.GetDisablePathCorrectionRedirection() + fireMethodNotAllowed = config.GetFireMethodNotAllowed() + enablePathIntelligence = config.GetEnablePathIntelligence() + forceLowercaseRouting = config.GetForceLowercaseRouting() + } + return &routerHandler{ - disablePathCorrection: config.GetDisablePathCorrection(), - disablePathCorrectionRedirection: config.GetDisablePathCorrectionRedirection(), - fireMethodNotAllowed: config.GetFireMethodNotAllowed(), - enablePathIntelligence: config.GetEnablePathIntelligence(), - forceLowercaseRouting: config.GetForceLowercaseRouting(), + disablePathCorrection: disablePathCorrection, + disablePathCorrectionRedirection: disablePathCorrectionRedirection, + fireMethodNotAllowed: fireMethodNotAllowed, + enablePathIntelligence: enablePathIntelligence, + forceLowercaseRouting: forceLowercaseRouting, logger: logger, } }