Sha256: 0e11a35efd9353e5f3c8cde28e0a2e25dce29d84b388d252a602282b2cb454ef
Contents?: true
Size: 779 Bytes
Versions: 2
Compression:
Stored size: 779 Bytes
Contents
#!/usr/bin/env ruby $:<< '../lib' << 'lib' require 'goliath' require 'yajl' if RUBY_PLATFORM != 'java' class AsyncUpload < Goliath::API use Goliath::Rack::Params # parse & merge query and body parameters use Goliath::Rack::DefaultMimeType # cleanup accepted media types use Goliath::Rack::Render, 'json' # auto-negotiate response format def on_headers(env, headers) env.logger.info 'received headers: ' + headers.inspect env['async-headers'] = headers end def on_body(env, data) env.logger.info 'received data: ' + data (env['async-body'] ||= '') << data end def on_close(env) env.logger.info 'closing connection' end def response(env) [200, {}, {body: env['async-body'], head: env['async-headers']}] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
goliath-1.0.0 | examples/async_upload.rb |
goliath-1.0.0.beta.1 | examples/async_upload.rb |