Class: Strapi::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/strapi/connection.rb

Overview

The singleton class representing the Faraday connection to Strapi

Class Method Summary collapse

Class Method Details

.instanceObject



7
8
9
# File 'lib/strapi/connection.rb', line 7

def instance
  @instance ||= Faraday::Connection.new("#{ENV['STRAPI_HOST_URL']}/api", options)
end

.optionsObject



11
12
13
14
15
16
17
18
19
# File 'lib/strapi/connection.rb', line 11

def options
  return unless (api_token = ENV['STRAPI_API_TOKEN'].presence)

  {
    headers: {
      'Authorization' => "bearer #{api_token}"
    }
  }
end