Remove unnecessary code
This commit is contained in:
parent
3755b56cb6
commit
55e362b812
1 changed files with 0 additions and 59 deletions
|
@ -19,8 +19,6 @@ module Diversipub
|
|||
|
||||
private
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
|
||||
def builder
|
||||
@builder ||= Rack::Builder.new.tap do |builder|
|
||||
builder.use Rack::Head
|
||||
|
@ -28,16 +26,11 @@ module Diversipub
|
|||
builder.use Rack::ShowStatus
|
||||
builder.use Rack::ContentLength
|
||||
builder.use Rack::Protection, except: %i[session_hijacking]
|
||||
builder.map '/.well-known/webfinger' do
|
||||
run Webfinger.new
|
||||
end
|
||||
builder.use Rack::Static, **rack_static_kwargs
|
||||
builder.run rest
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def rack_static_kwargs
|
||||
@rack_static_kwargs ||= {
|
||||
cascade: true,
|
||||
|
@ -50,57 +43,5 @@ module Diversipub
|
|||
def rest
|
||||
@rest ||= ->(_) { [200, {}, ['Hello, World!']] }
|
||||
end
|
||||
|
||||
##
|
||||
# Webfinger endpoint.
|
||||
#
|
||||
class Webfinger
|
||||
JRD_JSON = 'application/jrd+json'
|
||||
|
||||
ACCT_RU = 'acct:ru@causa-arcana.com'
|
||||
ACCT_EN = 'acct:en@causa-arcana.com'
|
||||
|
||||
def call(env)
|
||||
request = Rack::Request.new env
|
||||
resource = request.params['resource']
|
||||
|
||||
data =
|
||||
case resource
|
||||
when ACCT_RU then build_data :ru
|
||||
when ACCT_EN then build_data :en
|
||||
else
|
||||
raise 'Unknown resource'
|
||||
end
|
||||
|
||||
[
|
||||
200,
|
||||
{
|
||||
Rack::CONTENT_TYPE => JRD_JSON,
|
||||
},
|
||||
[
|
||||
data.to_json,
|
||||
],
|
||||
]
|
||||
end
|
||||
|
||||
def build_data(name)
|
||||
{
|
||||
subject: "acct:#{name}@causa-arcana.com",
|
||||
aliases: [].freeze,
|
||||
links: [
|
||||
{
|
||||
rel: 'http://webfinger.net/rel/profile-page',
|
||||
type: 'text/html',
|
||||
href: "https://causa-arcana.com/#{name}/blog/feed.html",
|
||||
},
|
||||
{
|
||||
rel: 'http://webfinger.net/rel/profile-page',
|
||||
type: 'text/gemini; charset=utf-8',
|
||||
href: "gemini://causa-arcana.com/#{name}/blog/feed.gmi",
|
||||
},
|
||||
].freeze,
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue