ut_process: initial import of a URI template processor#16702
ut_process: initial import of a URI template processor#16702miri64 merged 2 commits intoRIOT-OS:masterfrom
Conversation
67b2f93 to
c5a3228
Compare
sys/include/ut_process.h
Outdated
| char *uri, size_t *uri_len); | ||
|
|
||
| /** | ||
| * @brief Extends a URI template by a given value set |
There was a problem hiding this comment.
Description is the same as for ut_process_extend()
There was a problem hiding this comment.
Yepp. They both do the same thing. ut_process_extend() takes a buffer (so an (array, length)-pair) as template input, while ut_process_extend_str() takes a string (so a \0-terminated char-array) as template input ;-).
sys/include/ut_process.h
Outdated
| } ut_process_var_t; | ||
|
|
||
| /** | ||
| * @brief Extends a URI template by a given value set |
There was a problem hiding this comment.
What does 'Extend' mean? Since this is the only function this module provides, I would expect it also does some template matching?
There was a problem hiding this comment.
That's the wording used in the RFC. It means that a variable is "set" or alternatively, the variable is removed altogether, if it is not provided with the value set.
There was a problem hiding this comment.
Apparently I was mistaking. The word 'extend' only appears once in the RFC and not in the context of setting the variables... Let me check again.
There was a problem hiding this comment.
Ahhhh the word I meant to use here was "expand". Will fix!
There was a problem hiding this comment.
Fixed! Luckily, strlen("extend") == strlen("expand"), so a simple search and replace and no formatting changes were required due to this flub-up. :'-).
There was a problem hiding this comment.
It means that a variable is "set" or alternatively, the variable is removed altogether, if it is not provided with the value set.
Why not also add this to the API doc?
There was a problem hiding this comment.
Do we explain what TCP means or how routing works as well? The word is used within the first sentence of the abstract of the RFC:
A URI Template is a compact sequence of characters for describing a
range of Uniform Resource Identifiers through variable expansion.
As such, I don't think it needs explaining.
There was a problem hiding this comment.
expansion: The string result obtained from a template expression after processing it according to its expression type, list of variable names, and value modifiers, as defined in Section 3.
There was a problem hiding this comment.
As a developer, I like it when an API documentation saves me time. And unlike TCP or routing, it's not common knowledge what a "URI template parser" does.
Anyway, feel free to squash.
There was a problem hiding this comment.
As a developer, I like it when an API documentation saves me time. And unlike TCP or routing, it's not common knowledge what a "URI template parser" does.
Come on. If as a developer you don't know, what a variable expansion is, maybe you should revisit programming 101 ;-P.
9d86dca to
c844c73
Compare
Contribution description
This provides a simple checker and processor for URI templates up to level 3 in accordance with RFC 6570.
Testing procedure
Unittests are provided, they orient themselves on the examples provided in the RFC. Just run
make -C tests/unittests tests-ut_process testfor a board of your choice.
Issues/PRs references
None.