Rack::LinkHeaders
Easy Link header management for rack responses.
Installation
Add this line to your application's Gemfile:
gem 'rack-link_headers', '~> 2.4'
And then execute:
bundle
Or install it yourself as:
gem install rack-link_headers
Usage
response.link "http://abc.de/", rel: :search
response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
response.headers["Link"]
# => <http://abc.de/>; rel="rel", <http://test.host/feed.xml>; rel="rss"; type="application/rss+xml"
Manual set Link header will be overridden. All links can be
accessed via links
:
response.link "http://abc.de/", rel: :search
response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
response.links
# => [
# {:url=>"http://abc.de/",
# :params=>{:ref=>:search}},
# {:url=>"http://test.host/feed.xml",
# :params=>{:rel=>:rss, :type=>"application/rss+xml"}}
# ]
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Add tests for your features.
- Add your features.
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Copyright © 2023, Jan Graichen