-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.rb
33 lines (25 loc) · 861 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
require "rubygems"
require "bundler/setup"
require 'goliath'
require 'em-synchrony/activerecord'
require 'grape'
require './app/apis/votes'
require './app/models/vote'
require 'goliath/rack/templates'
require 'goliath/plugins/latency'
class Application < Goliath::API
include Goliath::Rack::Templates # render templated files from ./views
use(Rack::Static, # render static files from ./public
:root => Goliath::Application.app_path("public"),
:urls => ["/favicon.ico", '/stylesheets', '/javascripts', '/images'])
plugin Goliath::Plugin::Latency # ask eventmachine reactor to track its latency
def recent_latency
Goliath::Plugin::Latency.recent_latency
end
def response(env)
case env['PATH_INFO']
when '/' then [200, {}, haml(:index)]
else ::Votes.call(env)
end
end
end