Documentation ¶
Index ¶
- type PostValidator
- type PreValidator
- type Rule
- func Chained(rule Rule, next ...Rule) Rule
- func Conditional(claimPredicate func() bool, validPredicate func() bool) Rule
- func DefaultValidator() Rule
- func Header(claim ruleset.HeaderPredicate, valid ruleset.HeaderPredicate) Rule
- func HeaderClaim(claim ruleset.HeaderPredicate) Rule
- func HeaderValid(valid ruleset.HeaderPredicate) Rule
- func NotSatisfied() Rule
- func Satisfied() Rule
- func Validator(preValidators []PreValidator, postValidators []PostValidator) Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostValidator ¶
PostValidator type is is introduced to implement the second part of the RFC about cache.
Q: What's the difference between this and a PreValidator? A: PreValidator runs BEFORE trying to get the cache, it cares only for the request
and if at least one PreValidator returns false then it just runs the original handler and stop there, at the other hand a PostValidator runs if all PreValidators returns true and original handler is executed but with a response recorder, also the PostValidator should return true to store the cached response. Last, a PostValidator accepts a context in order to be able to catch the original handler's response, the PreValidator checks only for request.
If a function of type of PostValidator returns true then the (shared-always) cache is allowed to be stored.
type PreValidator ¶
PreValidator like middleware, executes before the cache action begins, if a callback returns false then this specific cache action, with specific request, is ignored and the real (original) handler is executed instead.
I'll not add all specifications here I'll give the opportunity (public API in the httpcache package-level) to the end-user to specify her/his ignore rules too (ignore-only for now).
Each package, nethttp and fhttp should implement their own encapsulations because of different request object.
One function, accepts the request and returns false if should be denied/ignore, otherwise true. if at least one return false then the original handler will execute as it's and the whole cache action(set & get) should be ignored, it will be never go to the step of post-cache validations.
type Rule ¶
Rule a superset of validators
func Conditional ¶
Conditional returns a new rule witch has conditionals
func DefaultValidator ¶
func DefaultValidator() Rule
DefaultValidator returns a new validator which contains the default pre and post cache validators
func Header ¶
func Header(claim ruleset.HeaderPredicate, valid ruleset.HeaderPredicate) Rule
Header returns a new rule witch claims and execute the post validations trough headers
func HeaderClaim ¶
func HeaderClaim(claim ruleset.HeaderPredicate) Rule
HeaderClaim returns a header rule which cares only about claiming (pre-validation)
func HeaderValid ¶
func HeaderValid(valid ruleset.HeaderPredicate) Rule
HeaderValid returns a header rule which cares only about valid (post-validation)
func Satisfied ¶
func Satisfied() Rule
Satisfied returns a rule which allows anything, it's usually the last rule on chained rules if no next rule is given, but it can be used outside of a chain too as a default allow-all rule.
func Validator ¶
func Validator(preValidators []PreValidator, postValidators []PostValidator) Rule
Validator receives the preValidators and postValidators and returns a new Validator rule