Files
apinto/checker/checker-none.go
黄孟柱 7dfd612e3d router
2021-11-12 15:22:04 +08:00

43 lines
900 B
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 checker
import (
"strings"
)
var (
globalCheckerNone = &checkerNone{}
)
//checkerAll 实现了Checker接口能进行空值匹配
type checkerNone struct {
}
//Key 返回路由指标检查器带有完整规则符号的检测值
func (t *checkerNone) Key() string {
return "$"
}
//Value 返回路由指标检查器的检测值
func (t *checkerNone) Value() string {
return "$"
}
//Check 判断待检测的路由指标值是否满足检查器的匹配规则
func (t *checkerNone) Check(v string, has bool) bool {
//当待检测的路由指标值存在且值为空时匹配成功
if !has {
return false
}
return strings.TrimSpace(v) == ""
}
//CheckType 返回检查器的类型值
func (t *checkerNone) CheckType() CheckType {
return CheckTypeNone
}
//newCheckerAll 创建一个空值匹配类型的检查器
func newCheckerNone() *checkerNone {
return globalCheckerNone
}