mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 10:47:46 -05:00
DEV: Add usage example for anon cache cookie registration (#32283)
Adding an example for the plugin api `register_anonymous_cache_key`.
This commit is contained in:
@@ -103,6 +103,11 @@ class Plugin::Instance
|
||||
@idx = 0
|
||||
end
|
||||
|
||||
# Keys can only be lowercase letters
|
||||
# Example usage:
|
||||
# plugin.register_anonymous_cache_key :onlylowercase do
|
||||
# @request.cookies["cookie_name"].present? ? "1" : "0"
|
||||
# end
|
||||
def register_anonymous_cache_key(key, &block)
|
||||
key_method = "key_#{key}"
|
||||
add_to_class(Middleware::AnonymousCache::Helper, key_method, &block)
|
||||
|
||||
Reference in New Issue
Block a user