Class: Alchemy::JsonApi::PagesController
Instance Method Summary
collapse
Instance Method Details
#index ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/alchemy/json_api/pages_controller.rb', line 8
def index
allowed = [:page_layout, :urlname]
jsonapi_filter(page_scope, allowed) do |filtered_pages|
@pages = filtered_pages.result
if !@pages.all?(&:cache_page?)
render_pages_json(allowed) && return
elsif stale?(last_modified: @pages.maximum(:published_at), etag: @pages.max_by(&:cache_key)&.cache_key)
render_pages_json(allowed)
end
end
expires_in cache_duration, { public: @pages.none?(&:restricted?) }.merge(caching_options)
end
|
#show ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/alchemy/json_api/pages_controller.rb', line 23
def show
if !@page.cache_page?
render(jsonapi: api_page(load_page)) && return
end
if stale?(last_modified: last_modified_for(@page), etag: @page.cache_key)
render jsonapi: api_page(load_page)
end
expires_in cache_duration, { public: !@page.restricted? }.merge(caching_options)
end
|