Skip to content

Instantly share code, notes, and snippets.

@Wolfer
Created Apr 15, 2014
Embed
What would you like to do?
# srv.rb
$: << "../../lib" << "./lib"
require 'goliath'
require 'em-synchrony/activerecord'
class MessageLog < ActiveRecord::Base
end
class Srv < Goliath::API
use Goliath::Rack::Params
use Goliath::Rack::DefaultMimeType
use Goliath::Rack::Render, 'json'
def response(env)
env['rack.input'].rewind
body = env['rack.input'].read
MessageLog.create request: body
[200, {}, 'OK']
end
end
# 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