Expose an /api/v1/extensions endpoint.

We don't have any extensions listed or link this in the "endpoints" field on
actors yet. The endpoint also doesn't currently provide a way to expose any
additional metadata about an extension beyond its URL (in part because the
SWICG proposal currently doesn't include that).

We can add extensions to the endpoint's response by calling
Mastodon::Extension::register with the extension URL.
feature/extensions-endpoint
Surinna Curtis 2017-09-23 20:50:46 +00:00
parent 169d83f532
commit f02150468b
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
require 'mastodon/extension'
class Api::V1::ExtensionsController < Api::BaseController
def index
render json: Mastodon::Extension.all
end
end

View File

@ -238,6 +238,8 @@ Rails.application.routes.draw do
post :unmute
end
end
resources :extensions, only: :list
end
namespace :web do

View File

@ -0,0 +1,17 @@
class Mastodon::Extension
@@extensions = []
def self.register url
@extensions << Extension.new(url)
end
def self.all
@extensions
end
def initialize url
@url = url
end
attr_reader :url
end