Sha256: 98147a506d09e9e91082e882a01650b04003e3050214a6c5d7d65dcdad411aff
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
module Rack module Gyazo class Application attr_reader :image, :request def call(env) @env = env load_request if request.path == "/uploads" && request.post? load_image if !image.nil? image.upload [200, {'Content-Type' => 'text/plain'}, StringIO.new(image.url)] else [422, {'Content-Type' => 'text/plain'}, StringIO.new('imagedata not specified')] end else [404, {'Content-Type' => 'text/plain'}, StringIO.new('file not found')] end end protected def load_request @request = Rack::Request.new(@env) end def load_image if request.params["imagedata"] @image = ::Gyazo::Image.new(request.params["imagedata"]) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack_gyazo-0.1.2 | lib/rack/gyazo/application.rb |