xfy 2734b04d8f refactor: remove 16.8k lines of dead code across all internal packages
- Delete unused files: tempfile subsystem, matcher variants, server/internal
- Remove 200+ unused functions across proxy, ssl, lua, http2/3, stream, variable
- Fix proxy test type errors (backgroundRefresh ctx→Request)
- Move bench/tools mock backend into internal/testutil
- Remove corresponding test functions for all deleted code
2026-06-03 16:15:43 +08:00

60 lines
1.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package matcher 提供 nginx 风格的 location 匹配引擎实现。
//
// 该文件实现精确路径匹配器,使用 hash map 实现 O(1) 查找。
//
// 作者xfy
package matcher
import "github.com/valyala/fasthttp"
// ExactMatcher Hash Map 精确匹配器。
//
// 通过字符串等值比较实现 O(1) 时间复杂度的路径匹配,
// 对应 nginx 的 = 修饰符。
type ExactMatcher struct {
// handler 请求处理器
handler fasthttp.RequestHandler
// internal 是否为 internal location
internal bool
// path 精确匹配路径
path string
// priority 匹配优先级,精确匹配为 1最高
priority int
}
// NewExactMatcher 创建精确匹配器。
//
// 参数:
// - path: 精确匹配的路径
// - handler: 匹配成功后的请求处理器
// - priority: 优先级(通常设为 1
// - internal: 是否为 internal location
//
// 返回值:
// - *ExactMatcher: 精确匹配器实例
func NewExactMatcher(path string, handler fasthttp.RequestHandler, priority int, internal bool) *ExactMatcher {
return &ExactMatcher{
path: path,
handler: handler,
priority: priority,
internal: internal,
}
}
// Result 返回匹配结果。
//
// 返回值:
// - *MatchResult: 包含处理器和元数据的匹配结果
func (m *ExactMatcher) Result() *MatchResult {
return &MatchResult{
Handler: m.handler,
Path: m.path,
Priority: m.priority,
LocationType: LocationTypeExact,
Internal: m.internal,
}
}