add json ld route

This commit is contained in:
Sebastian Jambor 2023-01-25 09:48:38 +01:00
parent b75dde9c84
commit 5a49d96ebf
2 changed files with 23 additions and 0 deletions
app/controllers/api/v1
config

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'faraday'
class Api::V1::JsonLdController < Api::BaseController
include ActionController::Live
rescue_from ArgumentError do |e|
render json: { error: e.to_s }, status: 422
end
def show
url = params[:url]
api_response = Faraday.get(url, nil, {'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'})
response.headers['Content-Type'] = api_response.headers['Content-Type']
render body: api_response.body, status: api_response.status
end
end

View file

@ -544,6 +544,8 @@ Rails.application.routes.draw do
resource :activity_log, only: [:show], controller: 'activity_log'
get '/json_ld', to: 'json_ld#show'
resource :instance, only: [:show] do
resources :peers, only: [:index], controller: 'instances/peers'
resources :rules, only: [:index], controller: 'instances/rules'