Skip to content

Commit e1cbb4f

Browse files
committed
use uuid helper
1 parent 19522b5 commit e1cbb4f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/hooks/app/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def self.create(config:, endpoints:, log:)
6565

6666
# Use send to dynamically create POST route
6767
send(:post, full_path) do
68-
request_id = SecureRandom.uuid
68+
request_id = uuid
6969

7070
# Use captured values
7171
config = captured_config

lib/hooks/app/endpoints/catchall.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
require "grape"
44
require_relative "../../handlers/default"
5+
require_relative "../helpers"
56

67
module Hooks
78
module App
89
class CatchallEndpoint < Grape::API
10+
include Hooks::App::Helpers
11+
912
def self.mount_path(config)
1013
"#{config[:root_path]}/*path"
1114
end
1215

1316
def self.route_block(captured_config, captured_logger)
1417
proc do
15-
request_id = SecureRandom.uuid
18+
request_id = uuid
1619

1720
# Use captured values
1821
config = captured_config

lib/hooks/app/helpers.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# frozen_string_literal: true
22

3+
require "securerandom"
4+
35
module Hooks
46
module App
57
module Helpers
8+
# Generate a unique identifier (UUID)
9+
def uuid
10+
SecureRandom.uuid
11+
end
12+
613
# Enforce request size and timeout limits
714
def enforce_request_limits(config)
815
# Check content length (handle different header formats and sources)

0 commit comments

Comments
 (0)