-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ut_process: initial import of a URI template processor #16702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description is the same as for ut_process_extend()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhh the word I meant to use here was "expand". Will fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 test
for a board of your choice.
Issues/PRs references
None.