Class: Rack::Gyazo::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/gyazo/application.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rack/gyazo/application.rb', line 4

def call(env)
  @env = env
  if request.path == "/uploads" && request.post?
    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