Module: WolfCore::Integrations::RoutingOperations

Defined in:
lib/wolf_core/application/integrations/routing_operations.rb

Instance Method Summary collapse

Instance Method Details

#route_event_request(path:, body:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/wolf_core/application/integrations/routing_operations.rb', line 4

def route_event_request(path:, body:)
  environment = ENV['ENVIRONMENT']
  if environment == 'production'
    function_name = PATH_TO_FUNCTION_NAME_MAPPING[path]
    raise_service_error("Function name not found for path: #{path}") if function_name.blank?

    invoke_lambda(
      function_name: function_name,
      payload: body,
    )
  else
    domain_url = ENV['CURRENT_SAM_URL']
    async_http_post(url: "#{domain_url}/#{path}", body: body)
  end
end