-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathratpack-app.rb
executable file
·66 lines (48 loc) · 1.27 KB
/
ratpack-app.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env ruby
require 'rubygems'
begin
# Attempt to load github gem first
gem 'sinatra-sinatra'
rescue Gem::LoadError
end
require 'sinatra'
use Rack::ShowExceptions
configure do
require 'yaml'
config = YAML.load_file( File.dirname(__FILE__) + '/config/ratpack.yml' )
RATPACK_ROOT = File.dirname(__FILE__) unless defined?( RATPACK_ROOT )
require 'lib/ratpack'
Ratpack::Application.config = config
trap(:INT) do
Ratpack::Application.shutdown!
end
end
get '/' do
'<html><head><title>Talk!</title></head><body><h1>Talk!</h1></body></html>'
end
post '/xmpp/message' do
to = params[:to]
message = params[:message]
Ratpack::Application.xmpp.message( to, message ).to_xml
end
post '/xmpp/broadcast' do
to = params['recipients[]']
message = params[:message]
Ratpack::Application.xmpp.broadcast( message, to ).to_xml
end
post '/xmpp/pool' do
to = params[:pool]
message = params[:message]
Ratpack::Application.xmpp.pool( to, message ).to_xml
end
post '/amqp/:queue' do
queue = params[:queue]
message = params[:message]
Ratpack::Application.amqp.publish( queue, message ).inspect
end
post '/smtp' do
to = params[:to]
subject = params[:subject]
body = params[:body]
Ratpack::Application.smtp.send_message( to, subject, body ).inspect
end