add json ld route
This commit is contained in:
parent
b75dde9c84
commit
5a49d96ebf
2 changed files with 23 additions and 0 deletions
21
app/controllers/api/v1/json_ld_controller.rb
Normal file
21
app/controllers/api/v1/json_ld_controller.rb
Normal 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
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue