{ok: true} end end ! run API $ http localhost:9292 HTTP/1.1 200 OK Connection: keep-alive Content-Length: 11 Content-Type: text/plain Server: thin ! {:ok=>true}
get do {ok: true} end end ! run API $ http localhost:9292 HTTP/1.1 200 OK Connection: keep-alive Content-Length: 11 Content-Type: application/json Server: thin ! { "ok": true }
'v1' namespace :app1 do resources :users do get ':id' do User.find(params.id) end end end end $ http localhost:9292/quipper/v1/app1/users/1 HTTP/1.1 200 OK Connection: keep-alive Content-Length: 8 Content-Type: application/json Server: thin ! { "id": 1 }
expose :name end ! class API < Grape::API format :json resources :users do get ':id' do present User.find(params.id), with: UserEntity end end end HSBQFFOUJUZHFN͕7JFX୲ ʢKCVJMEFSͰ͍͏CVJMEFSςϯϓϨʔτ૬ʣ
expose :name end ! class API < Grape::API format :json resources :users do get ':id' do present User.find(params.id), with: UserEntity end end end $ http localhost:9292/users/1 HTTP/1.1 200 OK Connection: keep-alive Content-Length: 27 Content-Type: application/json Server: thin ! { "id": 1, "name": "Anonymous" }