🗽 APIのサンプルTwitterを模倣したサンプル(?)が、公式のGitHubのREADMEに書かれていたので転載。 app/api/Twitter.rbを作成して、次のようなコードを書きます。 module Twitter class API < Grape::API # versionは:headerや、:paramなどもあり version 'v1', using: :path, vendor: 'twitter' format :json helpers do def current_user @current_user ||= User.authorize!(env) end def authenticate! error!('401 Unauthorized', 401) unless current_user end end resource :statuses do d
![Grape - RailsでスピーディにAPIを作成!](https://cdn-ak-scissors.b.st-hatena.com/image/square/c2ea7e72d0d7f3ba6c237909f321e67ffbdaa24e/height=288;version=1;width=512/https%3A%2F%2Fmorizyun.github.io%2Fimg%2Fog_image.png)