Skip to content

Commit

Permalink
🚚 chore: changed StrictRouting with Strict
Browse files Browse the repository at this point in the history
  • Loading branch information
balcieren committed Sep 6, 2022
1 parent 853aeaa commit 9b6d62d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app.go
Expand Up @@ -135,7 +135,7 @@ type Config struct {
// By default this is disabled and both "/foo" and "/foo/" will execute the same handler.
//
// Default: false
StrictRouting bool `json:"strict_routing"`
Strict bool `json:"strict"`

// When set to true, enables case sensitive routing.
// E.g. "/FoO" and "/foo" are treated as different routes.
Expand Down Expand Up @@ -301,7 +301,7 @@ type Config struct {
ReduceMemoryUsage bool `json:"reduce_memory_usage"`

// FEATURE: v2.3.x
// The router executes the same handler by default if StrictRouting or CaseSensitive is disabled.
// The router executes the same handler by default if Strict or CaseSensitive is disabled.
// Enabling RedirectFixedPath will change this behaviour into a client redirect to the original route path.
// Using the status code 301 for GET requests and 308 for all other request methods.
//
Expand Down
4 changes: 2 additions & 2 deletions core.go
Expand Up @@ -251,7 +251,7 @@ func (app *App) addPrefixToRoute(prefix string, route *Route) *Route {
prettyPath = utils.ToLower(prettyPath)
}
// Strict routing, remove trailing slashes
if !app.config.StrictRouting && len(prettyPath) > 1 {
if !app.config.Strict && len(prettyPath) > 1 {
prettyPath = utils.TrimRight(prettyPath, '/')
}

Expand Down Expand Up @@ -309,7 +309,7 @@ func (app *App) register(method, pathRaw string, handlers ...Handler) IRouter {
pathPretty = utils.ToLower(pathPretty)
}
// Strict routing, remove trailing slashes
if !app.config.StrictRouting && len(pathPretty) > 1 {
if !app.config.Strict && len(pathPretty) > 1 {
pathPretty = utils.TrimRight(pathPretty, '/')
}
// Is layer a middleware?
Expand Down
2 changes: 1 addition & 1 deletion core_test.go
Expand Up @@ -482,7 +482,7 @@ func Benchmark_Router_Handler(b *testing.B) {

func Benchmark_Router_Handler_Strict_Case(b *testing.B) {
app := New(Config{
StrictRouting: true,
Strict: true,
CaseSensitive: true,
})
registerDummyRoutes(app)
Expand Down
2 changes: 1 addition & 1 deletion ctx.go
Expand Up @@ -1504,7 +1504,7 @@ func (c *Ctx) configDependentPaths() {
c.detectionPathBuffer = utils.ToLowerBytes(c.detectionPathBuffer)
}
// If StrictRouting is disabled, we strip all trailing slashes
if !c.app.config.StrictRouting && len(c.detectionPathBuffer) > 1 && c.detectionPathBuffer[len(c.detectionPathBuffer)-1] == '/' {
if !c.app.config.Strict && len(c.detectionPathBuffer) > 1 && c.detectionPathBuffer[len(c.detectionPathBuffer)-1] == '/' {
c.detectionPathBuffer = utils.TrimRightBytes(c.detectionPathBuffer, '/')
}
c.detectionPath = c.app.getString(c.detectionPathBuffer)
Expand Down

1 comment on commit 9b6d62d

@ReneWerner87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 9b6d62d Previous: 036decf Ratio
Benchmark_Ctx_Protocol 20.06 ns/op 0 B/op 0 allocs/op 3.116 ns/op 0 B/op 0 allocs/op 6.44

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.