mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 15:26:36 +08:00
feat(http): make trailing-slash redirect configurable
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package driver_http
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBuildEngineDefaultRedirectsTrailingSlash(t *testing.T) {
|
||||
eng, err := BuildEngineWithConfig(httpAppConfig{}, httpRedisConfig{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !eng.RedirectTrailingSlash {
|
||||
t.Fatal("default RedirectTrailingSlash must be true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildEngineCanDisableRedirectTrailingSlash(t *testing.T) {
|
||||
eng, err := BuildEngineWithConfig(httpAppConfig{RedirectTrailingSlash: boolPtr(false)}, httpRedisConfig{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if eng.RedirectTrailingSlash {
|
||||
t.Fatal("RedirectTrailingSlash must honor false")
|
||||
}
|
||||
}
|
||||
|
||||
func boolPtr(v bool) *bool { return &v }
|
||||
Reference in New Issue
Block a user