Sha256: ce3a2a6ce5be1f844e7aab762d3a848346dd49ce5ee63bf1ddd5a226a30f2e00
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
#!/usr/bin/env ruby $:<< '../lib' << 'lib' require 'goliath' require 'goliath/plugins/latency' # Goliath uses multi-json, so pick your favorite JSON serializer # require 'json' require 'yajl' if RUBY_PLATFORM != 'java' class Echo < Goliath::API use Goliath::Rack::Tracer # log trace statistics use Goliath::Rack::DefaultMimeType # cleanup accepted media types use Goliath::Rack::Render, 'json' # auto-negotiate response format use Goliath::Rack::Params # parse & merge query and body parameters use Goliath::Rack::Heartbeat # respond to /status with 200, OK (monitoring, etc) # If you are using Golaith version <=0.9.1 you need to Goliath::Rack::ValidationError # to prevent the request from remaining open after an error occurs #use Goliath::Rack::ValidationError use Goliath::Rack::Validation::RequestMethod, %w(GET POST PATCH) # allow GET, POST and PATCH requests only use Goliath::Rack::Validation::RequiredParam, {:key => 'echo'} # must provide ?echo= query or body param plugin Goliath::Plugin::Latency # output reactor latency every second def process_request logger.info "Processing request" {response: env.params['echo']} end def response(env) [200, {}, process_request] end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
goliath-1.0.7 | examples/echo.rb |
goliath-1.0.6 | examples/echo.rb |
goliath-1.0.5 | examples/echo.rb |
goliath-1.0.4 | examples/echo.rb |
goliath-1.0.3 | examples/echo.rb |