uritemplate 1.0.0

RFC 6570 URI Template expansion implementation


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

uritemplate

An IETF RFC 6570 URI Template expansion implementation for the D programming language.

URI templates can be used for example in REST APIs to indicate related APIs to call, while being able to modify and extend URIs for future updates. This is for example used by the GitHub API.

This library can be used for

  • Expansion
  • Strict validation
  • @safe code

It's using idiomatic D code and the standard phobos style guide. Samples from the RFC are included as unittests and documented as such if you wish to view the source code. As the "Expansion" part of the RFC is fully implemented, no extensions to the code are currently planned. @nogc / buffer based outputs may be added if desired.

Example

import uritemplate;

string uriTemplate = "https://cool.webfreak.org/{user}/profile{?fields*}";

assert(uriTemplate.expandTemplateURIString([
	"user": URIVariable("bob"),
	"fields": URIVariable([
		"address", "name", "birthday"
	])
]) == "https://cool.webfreak.org/bob/profile?fields=address&fields=name&fields=birthday");

assert(uriTemplate.expandTemplateURIString([
	"user": URIVariable(["bob!", "Straße"]),
	"fields": URIVariable([
		"address", "name", "birthday"
	])
]) == "https://cool.webfreak.org/bob%21,Stra%C3%9Fe/profile?fields=address&fields=name&fields=birthday");

The code has 100% test coverage and is well documented. Refer to the auto-generated dpldocs page for documentation or use an IDE plugin for in-editor documentation. It was originally intended for the dub registry to properly use the GitHub API, but was separated to its own package due to the high conformity and usability.

This project is released under the unlicense, a public domain license. Feel free to use this code however you want without any restrictions. See LICENSE.md for details.

Authors:
  • webfreak
Dependencies:
none
Versions:
1.0.0 2021-May-06
~master 2021-May-06
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 177 downloads total

Score:
0.8
Short URL:
uritemplate.dub.pm