From 3ccb12d55d972adb008af8e3307522f062e55f22 Mon Sep 17 00:00:00 2001 From: Derek Leadbetter Date: Tue, 25 Apr 2023 14:03:37 -0400 Subject: [PATCH] IIIF #30 - Adding /public/resources/:id/manifest API endpoint --- app/controllers/public/resources_controller.rb | 7 ++++++- config/routes.rb | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/public/resources_controller.rb b/app/controllers/public/resources_controller.rb index b9dbce3..7ad8ee8 100644 --- a/app/controllers/public/resources_controller.rb +++ b/app/controllers/public/resources_controller.rb @@ -1,7 +1,12 @@ class Public::ResourcesController < Api::ResourcesController # Actions prepend_before_action :set_project, only: [:create, :update] - prepend_before_action :set_resource, only: [:show, :destroy, :update] + prepend_before_action :set_resource, only: [:show, :destroy, :update, :manifest] + + def manifest + resource = Resource.find(params[:id]) + render json: JSON.parse(resource.manifest) + end protected diff --git a/config/routes.rb b/config/routes.rb index c04ab82..f2eebe6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,11 @@ end namespace :public do - resources :resources, only: [:create, :show, :destroy, :update] + resources :resources, only: [:create, :show, :destroy, :update] do + member do + get :manifest + end + end end # Default route for static front-end