-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Deprecation Support #57
Conversation
.projections.json
Outdated
@@ -0,0 +1,4 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be in your ~/.gitignore
?
lib/stitches/deprecation.rb
Outdated
# Example: | ||
# | ||
# def show | ||
# deprecated on: "2019-04-09" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual argument name is to_be_retired_on
This is awesome, I'm excited for it! One thing I'm curious is the naming of the different bits in here. I see that in different places we use
|
@shawnacscott yeah, "deprecated" I'm using to mean "this will still work, but it's going to be retired", meaning it's deprecated the second we use the |
@shawnacscott I totally understand your point. One thing to note about "gone!" is that it is an actual thing in the HTTP spec: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/410. For this reason, the |
@brettfishman @shawnacscott I think both of your comments are right on. In 5e4f787 I changed it to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I like the naming you landed on.
This allows developers to indicate if an endopint is deprecated, when it will be gone, and to then make it explicitly gone.
Suppose you have a kittens-service and its endpoint
GET /api/floof_monsters
is going to be deprecated on May 4, 2019 (but you still want to keepGET /api/floof_monsters/:id
). You'd usedeprecated
method fromStitches::Deprecation
like so:This will cause the floof monsters
index
to behave exactly the same, with two exceptions:Sunset:
HTTP header will be set to the date given todeprecated
, in the proper HTTP formatYou can assert this is working in an acceptance test:
This expectation will check that the Sunset header is being added, but, more importantly, will fail after the retire date, telling you that you have a deprecated endpoint in production after the advertised retirement date. The endpoint will still work as before (this seems least surprising).
To then retire your endpoint, use
gone!
from the sameStitches::Deprecation
module:The
have_deprecation
matcher will succeed, but of course the rest of your test will fail since the endpoint is now not doing anything. To fix that, replace your test withbe_gone
:The reason to support the endpoint and have it return 410 vs. just removing it and responding with 404 is that if there are any stragglers still using the endpoint after the retirement date, it will be more obvious what is wrong than would be indicated by a 404.
Lastly, this also includes a migration to add the
Stitches::Deprecation
module to yourApiController
if you are already using stitches:Shipping This