HTTPResource
NAME
API::Discord::JSONy - Role for objects that can be serialised to JSON
API::Discord::RESTy - Role for objects that can be sent/received over REST
API::Discord::HTTPResource - Role for objects that can be CRUD'd
DESCRIPTION
This file defines the three roles listed above. They are all related to one another but not necessarily all required at once.
API::Discord::JSONy
This role defines the methods from-json
and to-json
that must be
implemented by the consuming class. Anything using this role can be sent to or
produced by RESTy.
API::Discord::RESTy[$base-url]
This role defines send
, fetch
, and remove
, and is parameterised with a
base URL. It abstracts over the top of an HTTP client, so requires get
,
post
, put
, and delete
methods.
It is intended to be applied to Cro::HTTP::Client, so the aforementioned methods should match those.
API::Discord::HTTPResource
Represents an object that can be discovered via some HTTP mechanism. The
consuming class is expected to have a hash called %.ENDPOINTS
, the purpose of
which is to provide a set of URL path templates that can be filled in by the
object being dealt with.
Endpoint handling is not yet fully implemented.
A gap in this process is that it does mean that in order to fetch an existing
object by ID, it is necessary to create an empty object containing that ID, and
then replace it with the response from read
, which will be a new object,
fully-populated.
Since all of the methods communicate via a RESTy object, it is currently necessary that the class consuming HTTPResource also consumes JSONy.