Deprecation and sunset middleware? #52906
Unanswered
gavinsykes
asked this question in
Ideas
Replies: 2 comments 3 replies
-
Wouldn't it be better to pass the link as a second parameter to |
Beta Was this translation helpful? Give feedback.
3 replies
-
Have a look at this package: https://github.com/jobilla/deprecated-routes-middleware |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings all! 👋
I'm working on an application where the topic of deprecation has been mentioned (by me, admittedly) for some of our endpoints, and that has led me down the path of, well, just how do you deprecate an endpoint?
A bit of research online suggests that there aren't really any official standards, though just last month an IETF proposal was published to standardise the addition of a
Deprecation
header. With that in mind, I have started work on a simple way of signifying deprecation on your endpoints.https://www.ietf.org/archive/id/draft-ietf-httpapi-deprecation-header-05.html
Middlewares
This is plainly in the territory of middlewares, so I have created 3 of them in the
\Illuminate\Http\Middleware
namespace:Deprecation
,Sunset
, andLink
.Deprecation
To mark an endpoint as deprecated, I would like to just be able to do the below:
Same for a group of endpoints, e.g.:
As it is right now, this will add a middleware that adds a
Deprecation
header with a value of'true'
. (Because the header isDeprecation
, I have opted to have the method name and middleware match that, rather than->deprecated()
.Sunset
Deprecation eventually leads to sunsetting, for which I'm aiming for a similar syntax e.g.
Once we are past the sunset date, I believe we should automatically return a
410
status code.Sunsetting raises another question: should this middleware automatically add the
Deprecation
header also? I am inclined to say yes.Either way, it will add a
Sunset
header with the formatted date-timeTue, 24 Sep 2024 00:00:00 UTC
.Link
When sunsetting, you may want to link your users to the replacement route (although there may not always be one). Make this accept either a relative path or an absolute URL.
I'd love to hear the community's thoughts on these, and if they're worth adding in to the framework!
Beta Was this translation helpful? Give feedback.
All reactions