-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbasic_api.rb
33 lines (29 loc) · 974 Bytes
/
basic_api.rb
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
require 'http.rb'
class BasicApi < HttpNode
def initialize(list)
@list = list;
super();
end
def on_request(s, req)
action = req.remaining;
ch = @list[s.udata[:user]];
rep = HttpResponse.new(req.proto, 200, "OK");
if(ch == nil)
msg = JsonManager.create_message(JsonManager::MSG_LVL_WARNING,
"Unknown channel #{channelName}");
rep.setData("<html><head><title>Channel not found</title></head><body><H1>Channel #{s.udata[:user]}not found</H1></body></head>");
else
case(action)
when "previous"
rep.setData("<html><head><title>Previous</title></head><body><H1>Previous</H1></body></head>");
ch.previous()
when "next"
rep.setData("<html><head><title>next</title></head><body><H1>Next</H1></body></head>");
ch.next()
else
rep = HttpResponse.generate404(req);
end
end
s.write(rep.to_s);
end
end