Module: Nesta::Plugin::Drop::Routes

Included in:
App
Defined in:
lib/nesta-plugin-drop/routes.rb

Class Method Summary collapse

Class Method Details

.included(app) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/nesta-plugin-drop/routes.rb', line 5

def self.included(app)
  app.post "/nestadrop" do
    if !nestadrop_request?
      status 404
    else
      if params["file"]
        Thread.new do
          Nesta::Plugin::Drop::Client.cache_file(params["file"])
        end
      else
        Thread.new do
          Nesta::Plugin::Drop::Client.cache_files
        end
      end
      status 200
      ""
    end
  end

  app.delete "/nestadrop" do
    if !nestadrop_request?
      status 404
    else
      if params["file"]
        Thread.new do
          Nesta::Plugin::Drop::Client.remove_file(params["file"])
        end
      end
      status 200
      ""
    end
  end
end