Sha256: b32dbf4a4df5b1addd5ef9c678d73407b0ae10bc079a58aa86b4353182972a9d
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
# -*- encoding : utf-8 -*- $: << File.dirname(__FILE__) require 'bundler/setup' require 'goliath' require 'em-synchrony/activerecord' require 'untied' require 'untied-publisher' require 'models/user' # Defining which ActiveRecord lifecycle events will be observed class Doorkeeper include Untied::Publisher::Doorkeeper def initialize # Everytime the User's after_create is fired, it will send the user # through the message bus watch User, :after_create end end Untied::Publisher.config.doorkeeper = Doorkeeper # Initializing the publisher observer Untied::Publisher::Observer.instance class Srv < Goliath::API use Goliath::Rack::Params use Goliath::Rack::DefaultMimeType use Goliath::Rack::Render, 'json' def response(env) if env['REQUEST_METHOD'] == 'GET' begin user = User.find(params['id']) [200, {}, user.to_json] rescue ActiveRecord::RecordNotFound => e [404, {}, {:error => e.message}.to_json] end else user = User.create(params) [200, {}, user.to_json] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
untied-0.0.7.pre3 | examples/goliath/srv.rb |
untied-0.0.5 | examples/goliath/srv.rb |
untied-0.0.4 | examples/goliath/srv.rb |
untied-0.0.1 | examples/goliath/srv.rb |