Skip to content

Commit cbce221

Browse files
committed
Remove format configuration option and update related documentation
1 parent cc56829 commit cbce221

File tree

10 files changed

+6
-25
lines changed

10 files changed

+6
-25
lines changed

docs/configuration.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,9 @@ When set to `true`, normalizes incoming HTTP headers by lowercasing and trimming
105105

106106
**Default:** `true`
107107

108-
### `format`
109-
110-
Sets the request/response format for the webhook server. This determines how incoming requests are parsed and how responses are formatted.
111-
112-
**Default:** `json`
113-
**Valid values:** `json`, `txt`, `xml`, `any`
114-
**Example:** `json`
115-
116108
### `default_format`
117109

118-
Sets the default response format when no specific format is requested. This works in conjunction with the `format` setting to determine response formatting.
110+
Sets the default response format when no specific format is requested.
119111

120112
**Default:** `json`
121113
**Valid values:** `json`, `txt`, `xml`, `any`

docs/handler_plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Example response format:
7373
}
7474
```
7575

76-
> **Note**: The JSON format behavior can be configured using the `format` and `default_format` options in your global configuration. See the [Configuration documentation](./configuration.md) for more details.
76+
> **Note**: The JSON format behavior can be configured using the `default_format` option in your global configuration. See the [Configuration documentation](./configuration.md) for more details.
7777

7878
### `payload` Parameter
7979

lib/hooks/app/api.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def self.create(config:, endpoints:, log:)
3939
content_type :xml, "application/xml"
4040
content_type :any, "*/*"
4141

42-
format config[:format] || :json
4342
default_format config[:default_format] || :json
4443
end
4544

lib/hooks/app/endpoints/catchall.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class CatchallEndpoint < Grape::API
2222
content_type :txt, "text/plain"
2323
content_type :xml, "application/xml"
2424
content_type :any, "*/*"
25-
format :json
2625
default_format :json
2726

2827
def self.mount_path(config)

lib/hooks/app/endpoints/health.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class HealthEndpoint < Grape::API
1111
content_type :txt, "text/plain"
1212
content_type :xml, "application/xml"
1313
content_type :any, "*/*"
14-
format :json
1514
default_format :json
1615

1716
get do

lib/hooks/app/endpoints/version.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class VersionEndpoint < Grape::API
1111
content_type :txt, "text/plain"
1212
content_type :xml, "application/xml"
1313
content_type :any, "*/*"
14-
format :json
1514
default_format :json
1615

1716
get do

lib/hooks/core/config_loader.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class ConfigLoader
2121
endpoints_dir: "./config/endpoints",
2222
use_catchall_route: false,
2323
normalize_headers: true,
24-
format: :json,
2524
default_format: :json
2625
}.freeze
2726

@@ -143,7 +142,6 @@ def self.load_env_config
143142
"HOOKS_ENDPOINTS_DIR" => :endpoints_dir,
144143
"HOOKS_USE_CATCHALL_ROUTE" => :use_catchall_route,
145144
"HOOKS_NORMALIZE_HEADERS" => :normalize_headers,
146-
"HOOKS_FORMAT" => :format,
147145
"HOOKS_DEFAULT_FORMAT" => :default_format,
148146
"HOOKS_SOME_STRING_VAR" => :some_string_var # Added for test
149147
}
@@ -159,7 +157,7 @@ def self.load_env_config
159157
when :use_catchall_route, :normalize_headers
160158
# Convert string to boolean
161159
env_config[config_key] = %w[true 1 yes on].include?(value.downcase)
162-
when :format, :default_format
160+
when :default_format
163161
# Convert string to symbol
164162
env_config[config_key] = value.to_sym
165163
else

lib/hooks/core/config_validator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ValidationError < StandardError; end
2727
optional(:endpoints_dir).filled(:string)
2828
optional(:use_catchall_route).filled(:bool)
2929
optional(:normalize_headers).filled(:bool)
30+
optional(:default_format).filled(:symbol, included_in?: %i[json txt xml any])
3031

3132
optional(:ip_filtering).hash do
3233
optional(:ip_header).filled(:string)

spec/acceptance/acceptance_tests.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,10 @@ def expired_unix_timestamp(seconds_ago = 600)
532532
response = make_request(:post, "/webhooks/boomtown_with_error", payload, json_headers)
533533
expect_response(response, Net::HTTPInternalServerError)
534534

535-
# With JSON default format, even string errors are JSON-encoded
536-
expect(response.content_type).to eq("application/json")
535+
expect(response.content_type).to eq("text/plain")
537536
expect(response.code).to eq("500")
538537

539-
# The error body should be the JSON-encoded string
540-
body = parse_json_response(response)
541-
expect(body).to eq("boomtown_with_error: the payload triggered a simple text boomtown error")
538+
expect(response.body).to match(/boomtown_with_error: the payload triggered a simple text boomtown error/)
542539
end
543540
end
544541

spec/unit/lib/hooks/core/config_loader_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
endpoints_dir: "./config/endpoints",
2121
use_catchall_route: false,
2222
normalize_headers: true,
23-
format: :json,
2423
default_format: :json
2524
)
2625
end
@@ -201,12 +200,10 @@
201200
end
202201

203202
it "converts format environment variables to symbols" do
204-
ENV["HOOKS_FORMAT"] = "txt"
205203
ENV["HOOKS_DEFAULT_FORMAT"] = "xml"
206204

207205
config = described_class.load
208206

209-
expect(config[:format]).to eq(:txt)
210207
expect(config[:default_format]).to eq(:xml)
211208
end
212209
end

0 commit comments

Comments
 (0)