-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
28 lines (24 loc) · 656 Bytes
/
app.rb
File metadata and controls
28 lines (24 loc) · 656 Bytes
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
require 'sinatra/base'
require 'eventmachine'
require "sinatra/json"
require 'awesome_print'
require 'json'
require 'require_all'
class MyApp < Sinatra::Application
attr_reader :request_payload
set :server,'thin'
set :show_exceptions, true
set :dump_errors, true
set :root, File.dirname(__FILE__)
before do
if self.request.media_type == "application/json" && request.content_length.to_i > 0
request.body.rewind
@request_payload = ActiveSupport::JSON.decode(request.body.read).deep_symbolize_keys!
end
end
get '/try' do
json "helloworld"
end
end
require_rel 'app/controllers'
MyApp.run! if $0 == "app.rb"