diff --git a/app/controllers/api/contents_controller.rb b/app/controllers/api/contents_controller.rb new file mode 100644 index 0000000..e6c0b67 --- /dev/null +++ b/app/controllers/api/contents_controller.rb @@ -0,0 +1,14 @@ +module Api + class ContentsController < ApplicationController + skip_before_action :verify_authenticity_token + + def index + if current_user + contents = current_user.contents.order(stream: :asc) + render json: { contents: } + else + render json: { message: 'ログインしてください' } + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index e406f5d..d21a40e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,4 +33,8 @@ resources :flags, only: %i[create destroy] resources :notifications, only: %i[create] end + + namespace :api do + resources :contents, only: [:index] + end end