Module: Roda::RodaPlugins::Sprockets::RequestMethods

Defined in:
lib/roda/plugins/sprockets.rb

Instance Method Summary collapse

Instance Method Details

#sprocketsObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/roda/plugins/sprockets.rb', line 133

def sprockets
  get self.roda_class.sprockets_regexp do |path|
    options                    = scope.sprockets_options
    env_sprockets              = scope.request.env.dup
    env_sprockets['PATH_INFO'] = path

    status, headers, response = options[:sprockets].call env_sprockets

    # Appease Rack::Lint
    if (300..399).include? status
      headers.delete("Content-type")
    end

    scope.response.status = status
    scope.response.headers.merge! headers

    response.is_a?(Array) ? response.join('\n') : response.to_s
  end
end