[riot-notifications] [RIOT-OS/RIOT] sys/net/application_layer/nanocoap: Add path prefix option (#11098)

Leandro Lanzieri notifications at github.com
Mon Mar 4 16:14:51 CET 2019

### Contribution description
Right now the path matching in nanocoap and gcoap is performed by using `strcmp` on the request URI-path and the registered path of the resource. There are some cases where all the requests with a certain prefix want to be passed to one handler for further processing.

For example a [LWM2M](https://www.omaspecworks.org/what-is-oma-specworks/iot/lightweight-m2m-lwm2m/) client may need that all the requests that have the prefix `/lwm2m/` are redirected to a single handler, instead of having to register in runtime a path per resource for every instance of every object (e.g. `/lwm2m/3111/0/5850`)

This adds path options to the coap resource and modifies the way the path is matched on a request. This gives the option to use the resource path string as a prefix to redirect all the requests that match that prefix to that handler.

The nanocoap_server example is modified to include a resource that registers a prefix. This PR also adapts all coap_resource_t structure initializations to use the field names.

### Testing procedure
Run the nanocoap server example, it includes now an `/echo/` resource that uses the prefix matching.

### Issues/PRs references
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * sys/net/application_layer/nanocoap: Add prefix path_opt
  * examples/nanocoap_server: Add echo resource and fix README

-- File Changes --

    M examples/cord_ep/main.c (17)
    M examples/cord_epsim/main.c (17)
    M examples/gcoap/gcoap_cli.c (11)
    M examples/nanocoap_server/README.md (10)
    M examples/nanocoap_server/coap_handler.c (44)
    M sys/include/net/nanocoap.h (22)
    M sys/net/application_layer/gcoap/gcoap.c (15)
    M sys/net/application_layer/nanocoap/nanocoap.c (10)
    M tests/nanocoap_cli/request_handlers.c (5)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190304/a30f793f/attachment-0001.html>

More information about the notifications mailing list