-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathui.rb
More file actions
88 lines (76 loc) · 1.94 KB
/
Copy pathui.rb
File metadata and controls
88 lines (76 loc) · 1.94 KB
1
2
3
4
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require_relative 'env'
class UI < Roda
plugin :render, engine: 'haml'
plugin :public
plugin :not_found
plugin :multi_route
plugin :partials
plugin :all_verbs
plugin :error_handler
plugin :json
include RodaUtils
include ViewHelpers
route do |r|
r.root {
view 'index'
}
r.on("render_template") {
r.is {
r.get {
name = r.params["template_name"]
locals = {
type: r.params["type"],
api: r.params["api"],
oracle: r.params["oracle"],
policy: r.params["policy"],
}
Renderer.call template_name: name, locals: locals
}
}
}
r.on("contract_compile") {
r.is {
r.get {
# name = r.params["contract_name"]
name = "Poolsureth"
Compiler.call(name: name, code: r.params["contract"])
}
}
}
# this needs to be removed from the final version - at the moment we need an API proxy because Oraclize hasn't published yet the solidity code to support passing HTTP headers to the oracle, which are required for some api providers (flightaware)
# note: TODO - use "trusted" VMs and docker containers http://docs.oraclize.it/#data-sources-computation
r.on("api") {
r.on("flights") {
r.on("providers") {
r.on(":provider_id") { |provider_id|
r.on("flights") {
r.on(":id") { |id|
r.is {
r.get {
# example: /api/flights/providers/flightaware/flights/BA1382
API.call(provider: :flightaware, id: id)
}
}
}
}
}
}
}
}
r.public
end
not_found do
view "not_found"
end
error do |err|
case err
when nil
# catch a proper error...
#
# when CustomError
# "ERR" # like so
else
raise err
end
end
end