xfy ca03c121d3 refactor(matcher): 提取 LocationType 常量并优化结构体字段布局
- 添加 LocationType 常量定义替代硬编码字符串
- 优化 MatchResult、ExactMatcher、NamedMatcher 结构体字段顺序
- RadixTree.Insert 添加 locationType 参数用于调试追踪
- 更新测试代码适配新接口

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 10:11:45 +08:00

37 lines
753 B
Go

package matcher
import (
"github.com/valyala/fasthttp"
)
// ExactMatcher Hash Map 精确匹配
type ExactMatcher struct {
handler fasthttp.RequestHandler
path string
priority int
}
// NewExactMatcher 创建精确匹配器
func NewExactMatcher(path string, handler fasthttp.RequestHandler, priority int) *ExactMatcher {
return &ExactMatcher{
path: path,
handler: handler,
priority: priority,
}
}
// Match 检查路径是否精确匹配
func (m *ExactMatcher) Match(path string) bool {
return m.path == path
}
// Result 返回匹配结果
func (m *ExactMatcher) Result() *MatchResult {
return &MatchResult{
Handler: m.handler,
Path: m.path,
Priority: m.priority,
LocationType: LocationTypeExact,
}
}