Module: Legion::Extensions::Rfp::Generate::Helpers::Client

Included in:
Client, Runners::Drafts, Runners::Sections, Runners::Templates
Defined in:
lib/legion/extensions/rfp/generate/helpers/client.rb

Instance Method Summary collapse

Instance Method Details

#client(base_url: 'http://localhost:4567', token: nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/legion/extensions/rfp/generate/helpers/client.rb', line 11

def client(base_url: 'http://localhost:4567', token: nil, **)
  Faraday.new(url: base_url) do |conn|
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.headers['Content-Type'] = 'application/json'
    conn.headers['Authorization'] = "Bearer #{token}" if token
  end
end