Skip to content

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Aug 3, 2021

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.

@github-actions github-actions bot added Area: sys Area: System Area: tests Area: tests and testing framework labels Aug 3, 2021
@miri64 miri64 added CI: run tests If set, CI server will run tests on hardware for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 3, 2021
@miri64 miri64 force-pushed the ut_process/feat/initial branch from 67b2f93 to c5a3228 Compare August 3, 2021 11:25
@miri64 miri64 requested a review from benpicco August 11, 2021 09:56
@benpicco benpicco requested a review from chrysn August 11, 2021 10:03
char *uri, size_t *uri_len);

/**
* @brief Extends a URI template by a given value set
Copy link
Contributor

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()

Copy link
Member Author

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 ;-).

} ut_process_var_t;

/**
* @brief Extends a URI template by a given value set
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

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!

Copy link
Member Author

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. :'-).

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

@miri64 miri64 Sep 16, 2021

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.

Copy link
Contributor

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.

Copy link
Member Author

@miri64 miri64 Sep 16, 2021

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.

@miri64 miri64 force-pushed the ut_process/feat/initial branch from 9d86dca to c844c73 Compare September 16, 2021 16:18
@miri64 miri64 merged commit 913573a into RIOT-OS:master Sep 17, 2021
@miri64 miri64 deleted the ut_process/feat/initial branch September 17, 2021 07:43
@benpicco benpicco added this to the Release 2021.10 milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants