SatCat5
satcat5::coap::Resource Class Reference

Detailed Description

Define a single CoAP resource.

See also
coap_resource.h, ResourceEcho, ResourceLog, ResourceServer.

Definition at line 47 of file coap_resource.h.

#include <coap_resource.h>

Inheritance diagram for satcat5::coap::Resource:
[legend]
Collaboration diagram for satcat5::coap::Resource:
[legend]

Public Member Functions

bool operator== (const Resource &other) const
 Comparison operators for comparing two URI-paths.
 
bool operator!= (const Resource &other) const
 Comparison operators for comparing two URI-paths.
 
satcat5::ip::Dispatchip () const
 Pointer to the parent's network interface.
 
satcat5::udp::Dispatchudp () const
 Pointer to the parent's network interface.
 
virtual bool request_get (Connection *obj, Reader *msg)
 Event handlers for GET, POST, PUT, and DELETE queries. More...
 
virtual bool request_post (Connection *obj, Reader *msg)
 Event handlers for GET, POST, PUT, and DELETE queries. More...
 
virtual bool request_put (Connection *obj, Reader *msg)
 Event handlers for GET, POST, PUT, and DELETE queries. More...
 
virtual bool request_delete (Connection *obj, Reader *msg)
 Event handlers for GET, POST, PUT, and DELETE queries. More...
 

Protected Member Functions

constexpr Resource (const char *uri_path)
 Simple constructor sets the URI path for the resource. More...
 
 Resource (ResourceServer *server, const char *uri_path)
 Alternate constructor automatically calls add_resource(). More...
 
 ~Resource () SATCAT5_OPTIONAL_DTOR
 Destructor is only accessible to the child object.
 

Static Protected Member Functions

static constexpr const char * normalize_uri (const char *uri)
 Remove leading slash from a user-provided path.
 

Protected Attributes

const char *const m_uri_path
 URI-Path for this resource.
 
ResourceServer *const m_server
 Optional pointer to the server object.
 

Private Attributes

Resourcem_next
 

Constructor & Destructor Documentation

◆ Resource() [1/2]

constexpr satcat5::coap::Resource::Resource ( const char *  uri_path)
inlineexplicitconstexprprotected

Simple constructor sets the URI path for the resource.

Use this constructor if you need constexpr, then call ResourceServer::add_resource() directly.

Definition at line 52 of file coap_resource.h.

◆ Resource() [2/2]

Resource::Resource ( ResourceServer server,
const char *  uri_path 
)
protected

Alternate constructor automatically calls add_resource().

Use this constructor to call ResourceServer::add_resource() and remove_resource() automatically.

Definition at line 18 of file coap_resource.cc.

Member Function Documentation

◆ request_delete()

virtual bool satcat5::coap::Resource::request_delete ( Connection obj,
Reader msg 
)
inlinevirtual

Event handlers for GET, POST, PUT, and DELETE queries.

The Child class SHOULD override at least one of the following event handlers corresponding to GET, POST, PUT, and DELETE requests, respectively. Default behavior is to respond with the 4.05 Method Not Allowed error code.

Reimplemented in satcat5::coap::ResourceError, and satcat5::coap::ProxyResource.

Definition at line 95 of file coap_resource.h.

◆ request_get()

virtual bool satcat5::coap::Resource::request_get ( Connection obj,
Reader msg 
)
inlinevirtual

Event handlers for GET, POST, PUT, and DELETE queries.

The Child class SHOULD override at least one of the following event handlers corresponding to GET, POST, PUT, and DELETE requests, respectively. Default behavior is to respond with the 4.05 Method Not Allowed error code.

Reimplemented in satcat5::coap::ResourceError, satcat5::coap::ResourceEcho, and satcat5::coap::ProxyResource.

Definition at line 89 of file coap_resource.h.

◆ request_post()

virtual bool satcat5::coap::Resource::request_post ( Connection obj,
Reader msg 
)
inlinevirtual

Event handlers for GET, POST, PUT, and DELETE queries.

The Child class SHOULD override at least one of the following event handlers corresponding to GET, POST, PUT, and DELETE requests, respectively. Default behavior is to respond with the 4.05 Method Not Allowed error code.

Reimplemented in satcat5::coap::ResourceLog, satcat5::coap::ResourceError, and satcat5::coap::ProxyResource.

Definition at line 91 of file coap_resource.h.

◆ request_put()

virtual bool satcat5::coap::Resource::request_put ( Connection obj,
Reader msg 
)
inlinevirtual

Event handlers for GET, POST, PUT, and DELETE queries.

The Child class SHOULD override at least one of the following event handlers corresponding to GET, POST, PUT, and DELETE requests, respectively. Default behavior is to respond with the 4.05 Method Not Allowed error code.

Reimplemented in satcat5::coap::ResourceError, and satcat5::coap::ProxyResource.

Definition at line 93 of file coap_resource.h.


The documentation for this class was generated from the following files: