Files
apinto/router-http/plan-multi.go
黄孟柱 a10d4b53a0 init
2021-07-20 11:11:39 +08:00

27 lines
549 B
Go
Raw 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 router_http
import (
"github.com/eolinker/goku-eosc/router"
"net/http"
)
type Checker_Multi interface {
check(request *http.Request) bool
}
// 适合从request检测多个值的类型如header、query读取request中需要检测的值在check中执行
type _Plan_Multi struct {
checkers []Checker_Multi
nexts []router.IRouterHandler
}
func (p *_Plan_Multi) Match(request *http.Request) (string, bool) {
for i, c := range p.checkers {
if c.check(request) {
return p.nexts[i].Match(request)
}
}
return "", false
}