Skip to content

Commit

Permalink
Add support for X-Group-Key header
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-sage authored Feb 29, 2024
1 parent fb6ec88 commit a93aea8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lockstep_rails (0.3.79)
lockstep_rails (0.3.80)
rails

GEM
Expand Down
22 changes: 22 additions & 0 deletions app/concepts/lockstep/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ def internal_service_key
RequestStore.store[:internal_service_key]
end

def self.set_x_group_key(x_group_key)
RequestStore.store[:lockstep_x_group_key] = x_group_key
true
end

def self.x_group_key
RequestStore.store[:lockstep_x_group_key]
end

def self.set_m2m_token(token)
# this method can be ommitted and we can use directly `set_bearer_token`
set_bearer_token(token)
end

##
# Construct a new Lockstep API client targeting the specified server.
#
Expand Down Expand Up @@ -81,6 +95,10 @@ def api_key
self.class.api_key
end

def x_group_key
self.class.x_group_key
end

##
# Configure this API to use an application name
#
Expand Down Expand Up @@ -139,6 +157,10 @@ def request(method, path, body, params)
request["Authorization"] = 'Bearer ' + bearer_token
end

if x_group_key != nil
request["X-Group-Key"] = x_group_key
end

# Send the request
http.request(request)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lockstep_rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module LockstepRails
VERSION = '0.3.79'
VERSION = '0.3.80'
end

0 comments on commit a93aea8

Please sign in to comment.