mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-15 16:47:38 +08:00
feat: add redirect host selection options
Support explicit redirect host source selection for HTTP-to-HTTPS redirects with ordered header lookup, fixed host mode, and strict validation. Document the new redirect option relationships and add focused tests for 426 fallback, conflict checks, and non-graceful startup errors.
This commit is contained in:
parent
e4d3eed379
commit
e2cf08d5dd
5 changed files with 422 additions and 35 deletions
10
engine.go
10
engine.go
|
|
@ -626,7 +626,7 @@ func (engine *Engine) combineHandlers(h1 HandlersChain, h2 HandlersChain) Handle
|
|||
|
||||
// Use 将全局中间件添加到 Engine
|
||||
// 这些中间件将应用于所有注册的路由
|
||||
func (engine *Engine) Use(middleware ...HandlerFunc) IRouter {
|
||||
func (engine *Engine) Use(middleware ...HandlerFunc) Router {
|
||||
engine.globalHandlers = append(engine.globalHandlers, middleware...)
|
||||
engine.rebuildFallbackChains()
|
||||
return engine
|
||||
|
|
@ -695,7 +695,7 @@ func (engine *Engine) GetRouterInfo() []RouteInfo {
|
|||
|
||||
// Group 创建一个新的路由组
|
||||
// 路由组允许将具有相同前缀路径和/或共享中间件的路由组织在一起
|
||||
func (engine *Engine) Group(relativePath string, handlers ...HandlerFunc) IRouter {
|
||||
func (engine *Engine) Group(relativePath string, handlers ...HandlerFunc) Router {
|
||||
return &RouterGroup{
|
||||
Handlers: engine.combineHandlers(engine.globalHandlers, handlers), // 继承全局中间件
|
||||
basePath: resolveRoutePath("/", relativePath),
|
||||
|
|
@ -704,7 +704,7 @@ func (engine *Engine) Group(relativePath string, handlers ...HandlerFunc) IRoute
|
|||
}
|
||||
|
||||
// RouterGroup 表示一个路由分组,可以添加组特定的中间件和路由
|
||||
// 它也实现了 IRouter 接口,允许嵌套分组
|
||||
// 它也实现了 Router 接口,允许嵌套分组
|
||||
type RouterGroup struct {
|
||||
Handlers HandlersChain // 组中间件,仅应用于当前组及其子组的路由
|
||||
basePath string // 组路径前缀
|
||||
|
|
@ -713,7 +713,7 @@ type RouterGroup struct {
|
|||
|
||||
// Use 将中间件应用于当前路由组
|
||||
// 这些中间件将应用于当前组及其子组的所有路由
|
||||
func (group *RouterGroup) Use(middleware ...HandlerFunc) IRouter {
|
||||
func (group *RouterGroup) Use(middleware ...HandlerFunc) Router {
|
||||
group.Handlers = append(group.Handlers, middleware...)
|
||||
return group
|
||||
}
|
||||
|
|
@ -759,7 +759,7 @@ func (group *RouterGroup) ANY(relativePath string, handlers ...HandlerFunc) {
|
|||
}
|
||||
|
||||
// Group 为当前组创建一个新的子组
|
||||
func (group *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) IRouter {
|
||||
func (group *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) Router {
|
||||
return &RouterGroup{
|
||||
Handlers: group.engine.combineHandlers(group.Handlers, handlers),
|
||||
basePath: resolveRoutePath(group.basePath, relativePath),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue