Closed kiddrew closed 7 years ago
Not sure if others have a better approach, but what I would do is put a before filter in the API version's base controller which halts any request to that version and returns the 426 status code and any response body you want.
Yeah, I did that, but the issue is the request doesn't get routed there because I removed the v1 routes. I could keep them around, but that feels sloppy.
Ah. So replace the v1 routes with a single catch-all v1 route that has the deprecation logic? You'll probably need to map this for all of the possible verbs used by v1.
get '/v1/*', to: 'foo#no_soup_for_you'
post '/v1/*', to: 'foo#no_soup_for_you'
put '/v1/*', to: 'foo#no_soup_for_you'
...etc...
Just thinking out loud here......
That's the Rails magic I was missing! Good call Brian, and thanks for a great gem.
👍
I know this isn't an "issue" with the gem, but I thought someone might have some ideas for how to achieve this. I used versionist for v1 of my API, and it's time to upgrade to v2. The thing is, I need to deprecate v1 and I would like those old routes to throw a 426 (upgrade required). If I simply remove the old routes, they will throw 404s instead.
Has anyone found a good solution for this?