class Middleman::Sitemap::Extensions::RequestEndpoints
def create_endpoint(path, opts={}, &block)
def create_endpoint(path, opts={}, &block) endpoint = { request_path: path } if block_given? endpoint[:output] = block else endpoint[:request_path] = opts[:path] if opts.key?(:path) end @endpoints[path] = endpoint @app.sitemap.rebuild_resource_list!(:added_endpoint) end
def initialize(app, config={}, &block)
Manages the list of proxy configurations and manipulates the sitemap
def initialize(app, config={}, &block) super @app.add_to_config_context(:endpoint, &method(:create_endpoint)) @endpoints = {} end
def manipulate_resource_list(resources)
def manipulate_resource_list(resources) resources + @endpoints.map do |path, config| r = EndpointResource.new( @app.sitemap, path, config[:request_path] ) r.output = config[:output] if config.key?(:output) r end end