Rack::LinkHeaders

Gem Version GitHub Workflow Status

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add tests for your features.
  4. Add your features.
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

License

MIT License

Copyright © 2023, Jan Graichen