Sha256: e1df1c481523b04c01202d0abdecc7ed908f7a8a1a6edf70effc92500f402a9c

Contents?: true

Size: 387 Bytes

Versions: 4

Compression:

Stored size: 387 Bytes

Contents

#!ruby -I ../lib -I lib
require 'nyny'
require 'json'

#
# Every response of this app will be automatically converted to json
#
class App < NYNY::App
  before { headers 'Content-Type' => 'application/json' }

  after do
    body = response.raw_body
    response.body = body.to_json if body.respond_to? :to_json
  end

  get '/' do
    {:some => [:json, :mate!]}
  end
end

App.run! 9000

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nyny-2.0.0 examples/json_api.rb
nyny-1.0.2 examples/json_api.rb
nyny-1.0.1 examples/json_api.rb
nyny-1.0.0 examples/json_api.rb