mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
20 lines
574 B
Ruby
20 lines
574 B
Ruby
module Api
|
|
module V1
|
|
class ApiController < ApplicationController
|
|
# Content page list endpoints
|
|
|
|
# Content page show endpoints
|
|
Rails.application.config.content_types[:all].each do |content_type|
|
|
define_method(content_type.name.downcase) do
|
|
page = content_type.find_by(id: params[:id])
|
|
|
|
if page && page.readable_by?(current_user || User.new)
|
|
render json: ApiContentSerializer.new(page).data
|
|
else
|
|
render json: { error: "Page not found" }
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end |