Skip to content

Instantly share code, notes, and snippets.

@tagomoris
Created December 11, 2017 07:56
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 tagomoris/ae068d7b2380095ab5e721d8c0b219d6 to your computer and use it in GitHub Desktop.
Save tagomoris/ae068d7b2380095ab5e721d8c0b219d6 to your computer and use it in GitHub Desktop.
access-log: /dev/null
hosts:
"localhost":
listen: 8384
paths:
"/t":
mruby.handler: |
class Foo
def initialize(ch, a)
@ch = ch
task do
@ch.push a
end
end
end
Proc.new do |env|
begin
ch = H2O::Channel.new
f1 = Foo.new(ch, "a")
f2 = Foo.new(ch, "b")
str = ''
2.times{ str << ch.shift }
[200, {}, [str]]
rescue => e
puts "Unexpected error #{e.class}:#{e.message}"
e.backtrace.each do |bt|
puts "\t#{bt}"
end
[500, {}, [e.message]]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment