Sha256: 26de4ff7b71bfd1aea20de3ce5d5a6dbb2b0b3c696bfab5a1666519939dfdc8e
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module G5K module Sinatra module Helpers def returning(thing = nil) yield thing thing end def provides *formats if params[:format].nil? || !formats.include?(params[:format].to_sym) throw :halt, [406, "The accepted types are: #{formats.join(", ")}"] end end def formatted_error(http_status, options = {}) parser = options.delete(:parser) format = options.delete(:format) || params[:format] || "txt" body = {:code => (options[:code] || http_status), :message => options[:message], :title => options[:title]} if defined?(::Sinatra::Application.logger) ::Sinatra::Application.logger.error(body.inspect) end content_type format.to_sym, :charset => 'utf-8' if (parser) body = parser.dump(body) else body = body.map{|(k,v)| [k,v].join("=")}.sort.join(";") end throw :halt, [http_status, body] end def compute_etag(*differentiators) Digest::SHA1.hexdigest(differentiators.join(".")) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cryx-g5k-0.2.4 | lib/g5k/sinatra/helpers.rb |