Sha256: 9d4657c023dc9fe60b66b6bf425f7997cbe00cb2cd9af44afaa552f1865fe6df
Contents?: true
Size: 908 Bytes
Versions: 8
Compression:
Stored size: 908 Bytes
Contents
module <%= module_name %> class <%= pluralize camelize(name) %>Controller < Sinatra::Base get '/<%= pluralize name %>/:id' do <%= name %> = <%= camelize name %>.get params[:id] json <%= name %>.to_hash(:get) end get '/<%= pluralize name %>' do <%= pluralize name %> = <%= camelize name %>.all json <%= pluralize name %>.to_hashes(:list) end post '/<%= pluralize name %>' do <%= pluralize name %> = <%= camelize name %>.post(posts) status 201 json <%= pluralize name %>.to_hash(:get) end patch '/<%= pluralize name %>/:id' do <%= name %> = <%= camelize name %>.get params[:id] <%= name %>.patch(posts) json <%= name %>.to_hash(:get) end delete '/<%= pluralize name %>/:id' do <%= name %> = <%= camelize name %>.get params[:id] <%= name %>.delete status 204 nil end end end
Version data entries
8 entries across 8 versions & 1 rubygems