struct Athena::Mercure::Grant
inherits Struct
#
Grants the actions on the topics to the holder of a JWT, such as subscribing to the updates of some topics.
The topics are either a list of topics that are matched exactly, or a hash mapping a topic matcher type, such as "urlpattern", to a list of patterns.
Matcher types other than "exact" require the Mercure protocol 1.0.
The optional payload is made available to the subscribers of the granted topics, so it requires the subscribe action. It is only supported by the Mercure protocol 1.0.
AMC::Grant.new :subscribe, ["https://example.com/books/1"]
AMC::Grant.new :subscribe, {"urlpattern" => ["https://example.com/books/:id"]}, JSON.parse(%({"user": "george"}))
AMC::Grant.new AMC::Grant::Action.flags(Subscribe, Publish), ["https://example.com/chat"]
Constructors#
.new(actions : Athena::Mercure::Grant::Action, topics : Array(String) | Hash(String, Array(String)), payload : JSON::Any | Nil = nil)#
Class methods#
.from(grants : Array(self) | Array(String) | Hash(String, Array(String)) | String) : Array(self)#
Returns grants from one of the shorthands accepted by AMC::Authorization:
a topic, a list of topics, or a hash of topic matchers to subscribe to, or the provided list of grants as is.