Skip to content

Instantly share code, notes, and snippets.

@eshapovalova
Created August 7, 2016 18:57
Show Gist options
  • Select an option

  • Save eshapovalova/cd91ad0529b0251deb2d12aa0bebd36b to your computer and use it in GitHub Desktop.

Select an option

Save eshapovalova/cd91ad0529b0251deb2d12aa0bebd36b to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using System.Net.Http;
using System.Web.Http.Routing;
 
namespace WebApiApp.Util
{
    public class CustomConstraint: IHttpRouteConstraint
    {
        private string uri;
        public CustomConstraint(string uri)
        {
            this.uri = uri;
        }
        public bool Match(HttpRequestMessage request, IHttpRoute route, string parameterName, 
            IDictionary<string, object> values, HttpRouteDirection routeDirection)
        {
            return !(uri == request.RequestUri.AbsolutePath);
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment