SatCat5
satcat5::coap::ProxyResource Class Referencefinal

Detailed Description

Define a reverse-proxy CoAP resource.

See also
coap_proxy.h, coap::Resource, coap::ProxyServer.

Definition at line 51 of file coap_proxy.h.

#include <coap_proxy.h>

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

Public Member Functions

 ProxyResource (satcat5::coap::ProxyServer *server, const char *local_uri, const satcat5::ip::Addr &fwd_addr, const satcat5::udp::Port &fwd_port, const char *fwd_uri=nullptr)
 Constructor sets the URI path for the resource. More...
 
bool request_get (Connection *obj, Reader *msg) override
 Forward GET, POST, PUT, and DELETE requests. More...
 
bool request_post (Connection *obj, Reader *msg) override
 Forward GET, POST, PUT, and DELETE requests. More...
 
bool request_put (Connection *obj, Reader *msg) override
 Forward GET, POST, PUT, and DELETE requests. More...
 
bool request_delete (Connection *obj, Reader *msg) override
 Forward GET, POST, PUT, and DELETE requests. More...
 
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.
 

Protected Member Functions

bool request_any (Connection *obj, Reader *msg)
 Event handler for all incoming requests. More...
 

Static Protected Member Functions

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

Protected Attributes

satcat5::coap::ProxyServer *const m_pool
 
const satcat5::ip::Addr m_fwd_addr
 
const satcat5::udp::Port m_fwd_port
 
const char *const m_fwd_uri
 
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

◆ ProxyResource()

ProxyResource::ProxyResource ( satcat5::coap::ProxyServer server,
const char *  local_uri,
const satcat5::ip::Addr fwd_addr,
const satcat5::udp::Port fwd_port,
const char *  fwd_uri = nullptr 
)

Constructor sets the URI path for the resource.

Parameters
serverPointer to the CoAP server object.
local_uriURI for incoming requests.
fwd_addrForwarding IP address.
fwd_portForwarding UDP port.
fwd_uriOptional forwarding URI, if different.

Definition at line 32 of file coap_proxy.cc.

Member Function Documentation

◆ request_any()

bool ProxyResource::request_any ( Connection obj,
Reader msg 
)
protected

Event handler for all incoming requests.

(The GET/POST/PUT/DELETE code is forwarded verbatim.)

Definition at line 47 of file coap_proxy.cc.

◆ request_delete()

bool satcat5::coap::ProxyResource::request_delete ( Connection obj,
Reader msg 
)
inlineoverridevirtual

Forward GET, POST, PUT, and DELETE requests.

Each handler is aliased to the same underlying function.

Reimplemented from satcat5::coap::Resource.

Definition at line 75 of file coap_proxy.h.

◆ request_get()

bool satcat5::coap::ProxyResource::request_get ( Connection obj,
Reader msg 
)
inlineoverridevirtual

Forward GET, POST, PUT, and DELETE requests.

Each handler is aliased to the same underlying function.

Reimplemented from satcat5::coap::Resource.

Definition at line 69 of file coap_proxy.h.

◆ request_post()

bool satcat5::coap::ProxyResource::request_post ( Connection obj,
Reader msg 
)
inlineoverridevirtual

Forward GET, POST, PUT, and DELETE requests.

Each handler is aliased to the same underlying function.

Reimplemented from satcat5::coap::Resource.

Definition at line 71 of file coap_proxy.h.

◆ request_put()

bool satcat5::coap::ProxyResource::request_put ( Connection obj,
Reader msg 
)
inlineoverridevirtual

Forward GET, POST, PUT, and DELETE requests.

Each handler is aliased to the same underlying function.

Reimplemented from satcat5::coap::Resource.

Definition at line 73 of file coap_proxy.h.


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