Skip to content
Browse files

switch to simpler text API for grape example

  • Loading branch information...
1 parent ae99306 commit 3ed77f65fbd8089a34a296e3fc9a7002a78585e3 @jch jch committed May 22, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 examples/grape/api.rb
View
12 examples/grape/api.rb
@@ -4,7 +4,7 @@
require 'redis/connection/synchrony'
class API < Grape::API
- default_format :json
+ default_format :txt
helpers do
include Rack::Stream::DSL
@@ -14,11 +14,10 @@ def redis
end
def build_message(text)
- m = {:text => text, :stream_transport => stream_transport}.to_json
- redis.rpush 'messages', m
+ redis.rpush 'messages', text
redis.ltrim 'messages', 0, 50
- redis.publish 'messages', m
- m
+ redis.publish 'messages', text
+ text
end
end
@@ -35,7 +34,8 @@ def build_message(text)
status 200
header 'Content-Type', 'application/json'
- redis.lrange 'messages', 0, 50
+ chunk *redis.lrange('messages', 0, 50)
+ ""
end
post do

0 comments on commit 3ed77f6

Please sign in to comment.
Something went wrong with that request. Please try again.