mirror of
https://github.com/glitch-soc/mastodon
synced 2025-04-25 06:34:52 +00:00
18 lines
439 B
Ruby
18 lines
439 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module DeprecationConcern
|
||
|
extend ActiveSupport::Concern
|
||
|
|
||
|
class_methods do
|
||
|
def deprecate_api(date, sunset: nil, **kwargs)
|
||
|
deprecation_timestamp = "@#{date.to_datetime.to_i}"
|
||
|
sunset = sunset&.to_date&.httpdate
|
||
|
|
||
|
before_action(**kwargs) do
|
||
|
response.headers['Deprecation'] = deprecation_timestamp
|
||
|
response.headers['Sunset'] = sunset if sunset
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|