Skip to content

Instantly share code, notes, and snippets.

@Wolfer
Created April 15, 2014 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wolfer/10720433 to your computer and use it in GitHub Desktop.
Save Wolfer/10720433 to your computer and use it in GitHub Desktop.
# 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