1 Star 1 Fork 0

teamlint / iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ruleset.go 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
// Package ruleset provides the basics rules which are being extended by rules.
package ruleset
// The shared header-mostly rules for both nethttp and fasthttp
var (
AuthorizationRule = func(header GetHeader) bool {
return header("Authorization") == "" &&
header("Proxy-Authenticate") == ""
}
MustRevalidateRule = func(header GetHeader) bool {
return header("Must-Revalidate") == ""
}
ZeroMaxAgeRule = func(header GetHeader) bool {
return header("S-Maxage") != "0" &&
header("Max-Age") != "0"
}
NoCacheRule = func(header GetHeader) bool {
return header("No-Cache") != "true"
}
)
// THESE ARE HERE BECAUSE THE GOLANG DOESN'T SUPPORTS THE F.... INTERFACE ALIAS, THIS SHOULD EXISTS ONLY ON /$package/rule
// or somehow move interface generic rules (such as conditional, header) here, because the code sharing is exactly THE SAME
// except the -end interface, this on other language can be designing very very nice but here no OOP so we stuck on this,
// it's better than before but not as I wanted to be.
// They will make me to forget my software design skills,
// they (the language's designers) rollback the feature of type alias, BLOG POSTING that is an UNUSEFUL feature.....
// GetHeader is a type of func which receives a func of string which returns a string
// used to get headers values, both request's and response's.
type GetHeader func(string) string
// HeaderPredicate is a type of func which receives a func of string which returns a string and a boolean,
// used to get headers values, both request's and response's.
type HeaderPredicate func(GetHeader) bool
// EmptyHeaderPredicate returns always true
var EmptyHeaderPredicate = func(GetHeader) bool {
return true
}
Go
1
https://gitee.com/teamlint/iris.git
git@gitee.com:teamlint/iris.git
teamlint
iris
iris
v11.1.1

搜索帮助