Sha256: 55e46d6ab1b1e3aef002f9f1378d220483fc051b74e7297b25147e75b1b717ff
Contents?: true
Size: 912 Bytes
Versions: 1
Compression:
Stored size: 912 Bytes
Contents
#!/usr/bin/env ruby $:<< '../lib' << 'lib' require 'goliath' require 'yajl' class AsyncUpload < Goliath::API # reload code on every request in dev environment use ::Rack::Reloader, 0 if Goliath.dev? use Goliath::Rack::Params # parse & merge query and body parameters use Goliath::Rack::DefaultMimeType # cleanup accepted media types use Goliath::Rack::Formatters::JSON # JSON output formatter use Goliath::Rack::Render # 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
goliath-0.9.0 | examples/async_upload.rb |