Skip to content

Sergej-Popov/IdeaSoftware.Utils.WebApi.Routing

Repository files navigation

IdeaSoftware.Utils.WebApi.Routing NuGet Version NuGet Version

Routing helpers for Web API

##Header Based Routing Allows for Web Api 2 controllers routing based on headers. Compatible with CORS.

###Route Based on Custom Header Value

[HeaderBasedRoute("/api/myroute", "my-custom-header", "valueA")]
public IHttpActionResult Get()
{
    return Ok();
}

###Bind multiple Headers to the same route

[HeaderBasedRoute("/api/myroute", "my-custom-headerA", "valueA")]
[HeaderBasedRoute("/api/myroute", "my-custom-headerB", "valueB")]
public IHttpActionResult Get()
{
    return Ok();
}

###Require Custom Header to be present with any value using wildcard

[HeaderBasedRoute("/api/myroute", "my-custom-header", "*")]

###Excluding routes based on header value with !

[HeaderBasedRoute("/api/myroute", "my-custom-header", "!valueB")]

###Working with CORS

[EnableCors("*", "*", "*", "my-custom-header")]
[HeaderBasedRoute("routeE", "my-custom-header", "*")]

About

Routing helpers for Web API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published