0

I have the following API method:

[Route("GetEditorialRequestsByCoordinates/{lat:double}/{lng:double}")] [AutomapperExceptionApiFilterAttribute] public HttpResponseMessage GetEditorialRequestsByCoordinates(double lat, double lng) { } 

it works fine for request like:

GET /v1/api/request/GetEditorialRequestsByCoordinates/48.999/2.777/ 

But I want to add limit (minimum and maximum) for lat and lng.

Follow this article: http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2

max Matches an integer with a maximum value. {x:max(10)}

min Matches an integer with a minimum value. {x:min(10)}

Try to create such route:

[Route("GetEditorialRequestsByCoordinates/{lat:double:min(-90):max(90)}/{lng:double:min(-180):max(180)}")] 

and I get 404 error. Why?

1 Answer 1

2

The documentation you give tells that functions works for integer

max: Matches an integer with a maximum value. {x:max(10)}

I think it does not work for double.

you can see this link to create your own IHttpRouteConstraint.

Sign up to request clarification or add additional context in comments.

3 Comments

I saw it, but understood it as we can set max(min) value only as integer value, but range will work for any number type
@OlegSh, you got this to work with range and double?
if you tell me I will write a code for you which support double for you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.