Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tpluscode/nancy.routing.uritemplates
Using URI Templates aka RFC 6570 for routing in Nancy
https://github.com/tpluscode/nancy.routing.uritemplates
nancy rest-api routing uri-template
Last synced: 15 days ago
JSON representation
Using URI Templates aka RFC 6570 for routing in Nancy
- Host: GitHub
- URL: https://github.com/tpluscode/nancy.routing.uritemplates
- Owner: tpluscode
- Created: 2016-11-13T18:16:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-18T17:23:57.000Z (about 5 years ago)
- Last Synced: 2024-10-24T02:35:31.923Z (22 days ago)
- Topics: nancy, rest-api, routing, uri-template
- Language: C#
- Homepage:
- Size: 184 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
![trail icon](https://raw.githubusercontent.com/tpluscode/Nancy.Routing.UriTemplates/master/assets/noun_27516.png)
# Nancy.Routing.UriTemplates [![Build status][av-badge]][build] [![NuGet version][nuget-badge]][nuget-link] [![codecov.io][cov-badge]][cov-link] [![codefactor][codefactor-badge]][codefactor-link]
Using [URI Templates aka RFC 6570](https://tools.ietf.org/html/rfc6570) for routing in Nancy.
## Introduction
You can use URI Templates to define routes in Nancy.
``` c#
public class PeopleModule : Nancy.Routing.UriTemplates.UriTemplateModule
{
public PeopleModule()
{
// by default you'll be creating typical routes
Get("person/{id}", p => GetModel(p.id));
// and URI Templates are opt-in
using(Templates)
{
Get("people{;include}{/page}{?name}", p => GetPeople(p.include, p.page, p.name));
}
}
}
```The second route will for example match a request to `people;include=hobbies,friends/4?name=Tomasz`
As you can see, URI Templates give more expressive syntax:
* variables can be extracted not only from segments but also other URI parts including query strings (`{?name}`) and path parameters (`{;include}`)
* all variables can have multiple valuesFinally, URI Templates can also be used outside routing to mint identifiers. For example to used them as links in a REST API.
## More
See some discussion here: http://t-code.pl/blog/2016/11/Towards-server-side-routing-with-URI-Templates/
[The icon](https://thenounproject.com/term/trail/27516/) desiged by [Gabriele Debolini](http://thenounproject.com/gabriele.debolini/) from [The Noun Project](http://thenounproject.com/)
[av-badge]: https://ci.appveyor.com/api/projects/status/so0uk5kw89371b3f?svg=true
[build]: https://ci.appveyor.com/project/tpluscode78631/nancy-routing-uritemplates/branch/master
[nuget-badge]: https://badge.fury.io/nu/nancy.Routing.UriTemplates.svg
[nuget-link]: https://badge.fury.io/nu/nancy.Routing.UriTemplates
[cov-badge]: https://codecov.io/github/tpluscode/Nancy.Routing.UriTemplates/coverage.svg?branch=master
[cov-link]: https://codecov.io/github/tpluscode/Nancy.Routing.UriTemplates?branch=master
[codefactor-badge]: https://www.codefactor.io/repository/github/tpluscode/Nancy.Routing.UriTemplates/badge/master
[codefactor-link]: https://www.codefactor.io/repository/github/tpluscode/Nancy.Routing.UriTemplates/overview/master