-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.rb
45 lines (37 loc) · 902 Bytes
/
server.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
34
35
36
37
38
39
40
41
42
43
44
45
require './environment'
require "sinatra/base"
class BaseServer < Sinatra::Application
LOGGER = Logger.new("log/server_#{ENV['RACK_ENV']}.log")
def response_json
request.body.rewind
JSON.parse(request.body.read, symbolize_names: true)
end
get '/ping' do
LOGGER.info "ping"
'pong'
end
post '/github/payload' do
status 200
body GitHub::Handler.new.call(response_json)
end
post '/gitlab/hooks/system' do
status 200
data = response_json
LOGGER.info "GitLab system hook:#{data}"
body Gitlab::Handler.new.call(data)
end
post '/gitlab/hooks/project' do
status 200
data = response_json
LOGGER.info "GitLab project hook:#{data}"
body Gitlab::Handler.new.call(data)
end
post '/gitlab/add_hook' do
status 200
body ""
end
post '/gitlab/refresh' do
status 200
body Workers::Projects.perform_async
end
end