Module: Roda::RodaPlugins::BridgetownWebfinger::ResponseMethods

Defined in:
lib/roda/plugins/bridgetown_webfinger.rb

Overview

Methods included in to the Roda response

Instance Method Summary collapse

Instance Method Details

#webfinger_error(message, status:) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders an error in the style of Bridgetown Webfinger

Parameters:

  • message (String)

    the error message for the response

  • status (Integer)

    the status code for the response

Returns:

  • (String)

    the response body

Since:

  • 0.1.0



125
126
127
128
129
130
# File 'lib/roda/plugins/bridgetown_webfinger.rb', line 125

def webfinger_error(message, status:)
  self["Content-Type"] = "application/json"
  self.status = status

  JSON.pretty_generate({error: message})
end

#webfinger_success(jrd) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders a JSON Resource Descriptor for Webfinger

Parameters:

Returns:

  • (String)

    the response body

Since:

  • 0.1.0



139
140
141
142
143
# File 'lib/roda/plugins/bridgetown_webfinger.rb', line 139

def webfinger_success(jrd)
  self["Content-Type"] = "application/jrd+json"

  JSON.pretty_generate(jrd.to_h)
end