Module: Nesta::Plugin::ContentFocus::Routes

Included in:
App
Defined in:
lib/nesta-plugin-contentfocus/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-contentfocus/routes.rb', line 5

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

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