mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
9f85b74fc9
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
44 lines
1.7 KiB
Go
44 lines
1.7 KiB
Go
// 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
|
|
}
|