Class: Holoserve::Interface

Inherits:
Goliath::API
  • Object
show all
Defined in:
lib/holoserve/interface.rb

Defined Under Namespace

Modules: Control Classes: Event, Fake

Constant Summary collapse

ROOT =
File.expand_path(File.join(File.dirname(__FILE__), "..", "..")).freeze

Instance Method Summary collapse

Constructor Details

#initializeInterface

Returns a new instance of Interface.



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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/holoserve/interface.rb', line 13

def initialize
  @router = Holoserve::Request::Router.new [
    {
      :method => :get,
      :path => "/_control/bucket",
      :handler => Control::Bucket::Fetch.new
    }, {
      :method => :delete,
      :path => "/_control/bucket",
      :handler => Control::Bucket::Delete.new
    }, {
      :method => :get,
      :path => "/_control/history",
      :handler => Control::History::Fetch.new
    }, {
      :method => :delete,
      :path => "/_control/history",
      :handler => Control::History::Delete.new
    }, {
      :method => :get,
      :path => "/_control/pairs",
      :handler => Control::Pair::Index.new
    }, {
      :method => :get,
      :path => "/_control/pairs/:id",
      :handler => Control::Pair::Fetch.new
    }, {
      :method => :put,
      :path => "/_control/state",
      :handler => Control::State::Update.new
    }, {
      :method => :get,
      :path => "/_control/state",
      :handler => Control::State::Fetch.new
    }, {
      :method => :delete,
      :path => "/_control/state",
      :handler => Control::State::Delete.new
    }, {
      :path => /^\//,
      :handler => Fake.new
    }
  ]
end

Instance Method Details

#response(environment) ⇒ Object



58
59
60
61
# File 'lib/holoserve/interface.rb', line 58

def response(environment)
  environment["parameters"] = environment.params
  @router.dispatch environment
end