CoAP lib of contiki erbium engine for arduino

Using the instance named CoAPServer to manage CoAP resources.
Define a custom resource like:
class HelloResource : public CoAPResource
{
protected:
  virtual void doGet(CoAPRequest& request, CoAPResponse& response)
  {
    const char *url;
    coapRequest.getPath(&url);
    response.setContentType(REST.type.TEXT_PLAIN);
    response.printf("hello world from %s", url);
  }
} resHello;

CoAPServer.init();
CoAPServer.addResource(&resHello);