路由調整
當專案架構大了,有非常多版本的 API 要維護管理,如果剛接手案子可能不視很清楚接口的狀況。
平常開發 rails 時可以用 rake routes
來查看所有路由,那麼 Grape 呢?
可以裝 grape_on_rails_routes
編輯 Gemfile
gem "grape_on_rails_routes"
bundle install
後
在專案目錄下輸入 rails grape:routes
$ rails grape:routes
GET | /:version/ping(.json) | v0 | Ping pong
GET | /:version/posts(.json) | v0 | Get all your posts
GET | /:version/posts/:id(.json) | v0 | Get your post
POST | /:version/posts(.json) | v0 | Create new post
PATCH | /:version/posts/:id(.json) | v0 | Update post
DELETE | /:version/posts/:id(.json) | v0 | Delete a post.
GET | /:version/swagger_doc(.:format) | v0 | Swagger compatible API description
GET | /:version/swagger_doc/:name(.:format) | v0 | Swagger compatible API description for specific API
就可以看到完整目錄了喔