Sha256: ecd7cbc2c8dbd1df20a04c10d539d84c5869fea54cf34cc5fb83f3beca86b2d6
Contents?: true
Size: 954 Bytes
Versions: 4
Compression:
Stored size: 954 Bytes
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 = {}) body = {:code => (options[:code] || http_status), :message => options[:message], :title => options[:title]} format = options[:format] || params[:format] || "txt" content_type format.to_sym, :charset => 'utf-8' if (parser = Parser.select(format.to_sym)) body = parser.dump(body) else body.map!{|(k,v)| [k,v].join("=")}.join(";") end error(http_status, body) end def compute_etag(*differentiators) Digest::SHA1.hexdigest(differentiators.join(".")) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cryx-g5k-0.1.0 | lib/g5k/sinatra/helpers.rb |
cryx-g5k-0.2.0 | lib/g5k/sinatra/helpers.rb |
cryx-g5k-0.2.1 | lib/g5k/sinatra/helpers.rb |
cryx-g5k-0.2.2 | lib/g5k/sinatra/helpers.rb |