blob: de019c30ef34f1f2e726bc363f3744f6d49a24e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# frozen_string_literal: true
class Api::V3::PostsController < Api::V3::ApiController
include BetterRateLimitable
skip_authorization_check only: :featured
before_action -> { rate_limit 60, 1.minute, 'You are submitting too many API requests!' }
before_action :setup_pagination_and_tags, :set_image_filter
def index
end
def show
post = Post.find(params[:id])
authorize! :read, post
if params[:legacy]
render json: PostSerializer.serialize(post)
else
render json: { post: PostSerializer.serialize(post) }
end
end
def featured
post = Post.featured
render json: { post: post ? PostSerializer.serialize(post) : nil }
end
end
|