Skip to content

Commit

Permalink
Change to moduler style
Browse files Browse the repository at this point in the history
  • Loading branch information
furukawataka02 committed Jan 2, 2016
1 parent 8124b65 commit 804ab25
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle install

WORKDIR /opt/sinatra-sidekiq-api
WORKDIR /opt/sinatra-sidekiq-example

EXPOSE 5000
26 changes: 14 additions & 12 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'sidekiq'
require 'sinatra'
require 'sinatra/base'
require 'sidekiq/web'

Sidekiq.configure_server do |config|
Expand All @@ -21,15 +21,17 @@ def perform(id)
end
end

get '/things' do
things = $redis.hvals('things')
things.to_json
end

post '/things' do
content_type :json
req = JSON.load(request.body.read.to_s)
$redis.hset('things', req['id'], req['thing'])
SomeWorker.perform_async(req['id'])
"enqueue #{req['id']}, #{req['thing']}"
class SomeApp < Sinatra::Application
get '/things' do
things = $redis.hvals('things')
things.to_json
end

post '/things' do
content_type :json
req = JSON.load(request.body.read.to_s)
$redis.hset('things', req['id'], req['thing'])
SomeWorker.perform_async(req['id'])
"enqueue #{req['id']}, #{req['thing']}"
end
end
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require './app'

run Rack::URLMap.new('/' => Sinatra::Application, '/sidekiq' => Sidekiq::Web)
run Rack::URLMap.new('/' => SomeApp, '/sidekiq' => Sidekiq::Web)

0 comments on commit 804ab25

Please sign in to comment.