diff --git a/README.md b/README.md
index 793d8a29..40fe99d7 100644
--- a/README.md
+++ b/README.md
@@ -228,13 +228,14 @@ With your help, we can improve Open Source web development for everyone!
+
+
-
@@ -246,6 +247,7 @@ With your help, we can improve Open Source web development for everyone!
+
@@ -291,6 +293,7 @@ With your help, we can improve Open Source web development for everyone!
+
@@ -298,6 +301,7 @@ With your help, we can improve Open Source web development for everyone!
+
@@ -305,31 +309,40 @@ With your help, we can improve Open Source web development for everyone!
+
+
+
+
+
+
+
+
+
@@ -347,6 +360,7 @@ With your help, we can improve Open Source web development for everyone!
+
@@ -356,6 +370,7 @@ With your help, we can improve Open Source web development for everyone!
+
diff --git a/context/request_params.go b/context/request_params.go
index ea9b6c0b..cc863758 100644
--- a/context/request_params.go
+++ b/context/request_params.go
@@ -48,7 +48,7 @@ func (r *RequestParams) Set(key, value string) {
// Get returns a path parameter's value based on its route's dynamic path key.
func (r *RequestParams) Get(key string) string {
- for i := 0; i < len(r.Store); i++ {
+ for i := range r.Store {
if kv := r.Store[i]; kv.Key == key {
if v, ok := kv.ValueRaw.(string); ok {
return v // it should always be string here on :string parameter.
diff --git a/core/router/handler.go b/core/router/handler.go
index 3ec5a483..87eaf9db 100644
--- a/core/router/handler.go
+++ b/core/router/handler.go
@@ -42,7 +42,13 @@ type (
)
type routerHandler struct {
- config context.ConfigurationReadOnly
+ // Config.
+ disablePathCorrection bool
+ disablePathCorrectionRedirection bool
+ fireMethodNotAllowed bool
+ enablePathIntelligence bool
+ forceLowercaseRouting bool
+ //
logger *golog.Logger
trees []*trie
@@ -60,8 +66,12 @@ var _ HTTPErrorHandler = (*routerHandler)(nil)
// to map the request with a route (aka mux implementation).
func NewDefaultHandler(config context.ConfigurationReadOnly, logger *golog.Logger) RequestHandler {
return &routerHandler{
- config: config,
- logger: logger,
+ disablePathCorrection: config.GetDisablePathCorrection(),
+ disablePathCorrectionRedirection: config.GetDisablePathCorrectionRedirection(),
+ fireMethodNotAllowed: config.GetFireMethodNotAllowed(),
+ enablePathIntelligence: config.GetEnablePathIntelligence(),
+ forceLowercaseRouting: config.GetForceLowercaseRouting(),
+ logger: logger,
}
}
@@ -200,7 +210,7 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
noLogCount++
}
- if h.config != nil && h.config.GetForceLowercaseRouting() {
+ if h.forceLowercaseRouting {
// only in that state, keep everything else as end-developer registered.
r.Path = strings.ToLower(r.Path)
}
@@ -393,9 +403,8 @@ func canHandleSubdomain(ctx *context.Context, subdomain string) bool {
func (h *routerHandler) HandleRequest(ctx *context.Context) {
method := ctx.Method()
path := ctx.Path()
- config := h.config // ctx.Application().GetConfigurationReadOnly()
- if !config.GetDisablePathCorrection() {
+ if !h.disablePathCorrection {
if len(path) > 1 && strings.HasSuffix(path, "/") {
// Remove trailing slash and client-permanent rule for redirection,
// if confgiuration allows that and path has an extra slash.
@@ -405,7 +414,7 @@ func (h *routerHandler) HandleRequest(ctx *context.Context) {
// use Trim to ensure there is no open redirect due to two leading slashes
path = "/" + strings.Trim(path, "/")
u.Path = path
- if !config.GetDisablePathCorrectionRedirection() {
+ if !h.disablePathCorrectionRedirection {
// do redirect, else continue with the modified path without the last "/".
url := u.String()
@@ -445,7 +454,7 @@ func (h *routerHandler) HandleRequest(ctx *context.Context) {
break
}
- if config.GetFireMethodNotAllowed() {
+ if h.fireMethodNotAllowed {
for i := range h.trees {
t := h.trees[i]
// if `Configuration#FireMethodNotAllowed` is kept as defaulted(false) then this function will not
@@ -460,7 +469,7 @@ func (h *routerHandler) HandleRequest(ctx *context.Context) {
}
}
- if config.GetEnablePathIntelligence() && method == http.MethodGet {
+ if h.enablePathIntelligence && method == http.MethodGet {
closestPaths := ctx.FindClosest(1)
if len(closestPaths) > 0 {
u := ctx.Request().URL