class

Marten::CDNCache::Rule

Inherits Reference < Object

A single classification rule: a matcher over the request + the Policy to apply when it matches. Build one with .path_prefix, .route_name, or .predicate. The middleware tries rules in order; first match wins.

Constructors

new(matcher : Matcher, policy : Policy)
path_prefix(prefix : String, policy : Policy) : Rule

Matches any request whose path starts with prefix (e.g. /assets/).

predicate(policy : Policy, &block : Marten::HTTP::Request -> Bool) : Rule

Matches when the supplied block returns true for the request.

route_name(name : String, policy : Policy) : Rule

Matches a request that resolves to the handler of the named route.

Limitation: only parameterless named routes are supported (the marketing / blog / static-page case). Routes that require parameters cannot be reversed without them — use .path_prefix or .predicate for those.

Instance methods

matches?(request : Marten::HTTP::Request) : Bool
policy

Nested types