https://github.com/jgraichen/rack-link_headers
Easy Link header management for rack responses.
https://github.com/jgraichen/rack-link_headers
Last synced: about 1 year ago
JSON representation
Easy Link header management for rack responses.
- Host: GitHub
- URL: https://github.com/jgraichen/rack-link_headers
- Owner: jgraichen
- License: mit
- Created: 2013-01-17T18:54:56.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2025-02-17T08:17:09.000Z (over 1 year ago)
- Last Synced: 2025-03-25T17:49:23.105Z (over 1 year ago)
- Language: Ruby
- Size: 53.7 KB
- Stars: 6
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Rack::LinkHeaders
[](https://rubygems.org/gems/rack-link_headers)
[](https://github.com/jgraichen/rack-link_headers/actions/workflows/test.yml)
Easy Link header management for rack responses.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'rack-link_headers', '~> 2.4'
```
And then execute:
```console
bundle
```
Or install it yourself as:
```console
gem install rack-link_headers
```
## Usage
```ruby
response.link "http://abc.de/", rel: :search
response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
```
```ruby
response.headers["Link"]
# => ; rel="rel", ; rel="rss"; type="application/rss+xml"
```
Manual set Link header will be overridden. All links can be
accessed via `links`:
```ruby
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](http://www.opensource.org/licenses/mit-license.php)
Copyright © 2023, Jan Graichen