class Rack::HostMeta

Rack middleware implementing the IETF draft: “Host Metadata for the Web” including support for Link-Pattern elements as described in the IETF draft: “Link-based Resource Descriptor Discovery.”

Usage:

use Rack::HostMeta do
  link :uri => '/robots.txt', :rel => 'robots'
  link :uri => '/w3c/p3p.xml', :rel => 'privacy', :type => 'application/p3p.xml'
  link :pattern => '{uri};json_schema', :rel => 'describedby', :type => 'application/x-schema+json'
end

See also:

http://tools.ietf.org/html/draft-nottingham-site-meta
http://tools.ietf.org/html/draft-hammer-discovery

TODO:

Accept POST operations allowing downstream services to register themselves

Public Class Methods

new(app, &block) click to toggle source
   # File lib/rack/contrib/host_meta.rb
24 def initialize(app, &block)
25   @app = app
26   @lines = []
27   instance_eval(&block)
28   @response = @lines.join("\n")
29 end

Public Instance Methods

call(env) click to toggle source
   # File lib/rack/contrib/host_meta.rb
31 def call(env)
32   if env['PATH_INFO'] == '/host-meta'
33     [200, {'Content-Type' => 'application/host-meta'}, [@response]]
34   else
35     @app.call(env)
36   end
37 end

Protected Instance Methods