[riot-notifications] [RIOT-OS/RIOT] gcoap: add a handler for request matching (#14029)
notifications at github.com
Thu May 28 15:54:13 CEST 2020
I had to look at how this is used in the proxy PR to understand how this is used.
I'm not convinced this is the right place to put this. It does appear to work, but AFAICT only for some limited patterns of application:
* The default handler
* Adding some condition to the default handler (eg. have one of your gcoap_listener that can only ever produce a match if requests come from, say, a given IP range -- or in virtual hosting, although that a) is niche and b) it'd need another data pointer for the conditional request_matcher function)
* Altering the URI matching rules
But is iterating over a `coap_resource_t` array applicable then at all? Wouldn't the entries probably look different?
One example of this would be LwM2M-style paths (`/3/0/22`), where the matcher function converts the path to a number, and the resources are stored as native numbers in the resource list. (For that case, it would be nice to hook into _find_resource loop and do the conversion once, rather than on every invocation in the loop).
* Accepting requests into a single entry on some condition (like the proxy case). This could be bent to dispatching to several handlers (say, a reverse proxy), but then you'd be already casting the `coap_resource_t` array into an array of, say, host names, and it would fall into the above category.
This works, but the latter mode is not immediately obvious from the documentation.
I'd think that the better point to hook into would be to replace the whole _find_resource loop as a whole rather than the function evaluated inside that loop. At that point, `resources` would become generic (`void*`) over whatever that matcher would like to iterate over (or `resources`/`resources_len` might even just be `data1` / `data2`). Then, the default or filtering case could still interpret their data as a length-tagged resources array, but others (like a reverse proxy) could interpret them as a next-hop lookup table, and yet others (like the forward proxy) would not loop over their resources at all but just treat `resources` as a handler directly if a Proxy option is present, and defer to the next otherwise.
So this is an improvement because it enables some more cases, but we should at least consider going the next step right away.
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...
More information about the notifications