We have a function to check whether an address is validate.
At first the url is like
/address/validate/{city}/{state}/{zipCode}
But later I thought that all the parameters for address is just one resource. So I changed it to
/address/validate/{city}.{state}.{zipCode}
I'm not sure which one is better, what's your advice?
In this case I would go for /address/validate?city={city}&state={state}&zipcode={zipCode}
Why? Well it is just my opinion. But think of paths (uris) as a unique identifier for a representation. Which usually is a part of your model domain. Since you are not storing (presumably) the result of the validation then just create a validate resource.
Think of it as a method. And the parameters are query-params.
So, doing this, the representation of validate (whether is valid) is modified by the params.
Think in rest as a representations, in your example I guess that /address/
exists as a resource, and it has a representation on your data model. So you can POST
, PUT
and or GET
to create, modify and retrieve.
But if you want a /address/validate
this is probably the result of the validation. SO I'd go with my example.