Skip to content

Instantly share code, notes, and snippets.

Created April 15, 2014 10:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# srv.rb
$: << "../../lib" << "./lib"
require 'goliath'
require 'em-synchrony/activerecord'
class MessageLog < ActiveRecord::Base
class Srv < Goliath::API
use Goliath::Rack::Params
use Goliath::Rack::DefaultMimeType
use Goliath::Rack::Render, 'json'
def response(env)
body = env['rack.input'].read
MessageLog.create request: body
[200, {}, 'OK']
# config/srv.rb
require 'mysql2'
ActiveRecord::Base.establish_connection(:adapter => 'em_mysql2',
:database => 'risb',
:username => 'root',
:password => '',
:host => 'localhost',
:pool => 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment