Module: EacEnvs::Http::Response::Links
- Defined in:
- lib/eac_envs/http/response/links.rb
Constant Summary collapse
- LINKS_HEADER_NAME =
'Link'
- LINK_PARSER =
/\A<(.+)>\s*;\s*rel\s*=\s*"(.*)"\z/.to_parser do |m| [m[2], m[1]] end
Instance Method Summary collapse
Instance Method Details
#link(rel) ⇒ Object
16 17 18 |
# File 'lib/eac_envs/http/response/links.rb', line 16 def link(rel) hash_search(links, rel) end |
#links ⇒ Object
20 21 22 23 24 |
# File 'lib/eac_envs/http/response/links.rb', line 20 def links header(LINKS_HEADER_NAME).if_present({}) do |v| v.split(',').to_h { |w| LINK_PARSER.parse!(w.strip) } end end |