Skip to content

A .NET library supporting RFC 6570 URI Templates (Level 4)

License

Notifications You must be signed in to change notification settings

pierewoj/dotnet-uritemplate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

UriTemplate.Core

This is a .NET library supporting RFC 6570 URI Templates (Level 4). It is compiled for .NET 4.5 and .NETStandard 1.6. You can download it from nuget https://www.nuget.org/packages/UriTemplate.Core.

Usage

Matching uri templates with this library is pretty straight-forward:

var variables = new Dictionary<string, object>{ { "id", "42" } };
var uriTemplate = new UriTemplate("www.campio.io/dolor/{id}");
var binding = uriTemplate.BindByName(variables);
Console.WriteLine(binding); //prints www.campio.io/dolor/42

There are also more complex templates supported:

var variables = new Dictionary<string, object>
{
    { "x", "foo" },
    { "y", "bar" }
};
var uriTemplate = new UriTemplate("www.campio.io/dolor{?x,y}");
var binding = uriTemplate.BindByName(variables);
Console.WriteLine(binding); //prints www.campio.io/dolor?x=foo&y=bar

For more examples I recommend reading RFC documentation or checking out unit tests.

About

A .NET library supporting RFC 6570 URI Templates (Level 4)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%