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
22
23
24
25
26
|
# 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 stale?(last_modified: @pages.maximum(:published_at), etag: @pages.max_by(&:cache_key)&.cache_key)
jsonapi_filter(page_scope_with_includes, allowed) do |filtered|
filtered_pages = filtered.result.map { |page| api_page(page) }
jsonapi_paginate(filtered_pages) do |paginated|
render jsonapi: paginated
end
end
end
end
expires_in cache_duration, { public: @pages.none?(&:restricted?) }.merge(caching_options)
end
|
#show ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'app/controllers/alchemy/json_api/pages_controller.rb', line 28
def show
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
|