Skip to content

Commit

Permalink
Convert header response to strings instead of symbols (#5)
Browse files Browse the repository at this point in the history
* Update app.rb

Change headers from symbols to strings

* Use double quotes to align with style guide

---------

Co-authored-by: viktorshamal <[email protected]>
  • Loading branch information
viktorshamal and strmstrm authored Oct 15, 2024
1 parent 0086188 commit 7cc692d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/apicraft/middlewares/introspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def call(env)

[
200,
{ 'Content-Type': "application/json" },
{ "Content-Type" => "application/json" },
[schema.to_json]
]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/apicraft/middlewares/mocker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call(env)
[
code.to_i,
{
'Content-Type': content_type
"Content-Type" => content_type
},
[
content&.send(convertor(content_type))
Expand Down
2 changes: 1 addition & 1 deletion lib/apicraft/middlewares/request_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def call(env)
rescue OpenAPIParser::OpenAPIError => e
[
config.request_validation_http_code,
{ 'Content-Type': content_type },
{ "Content-Type" => content_type },
[
response_body(e)&.send(convertor(content_type))
].compact
Expand Down
10 changes: 5 additions & 5 deletions lib/apicraft/web/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ def self.call(env)

[
200,
{ 'Content-Type': content_type },
{ "Content-Type" => content_type },
[content]
]
rescue Errors::RouteNotFound
[
404,
{ 'Content-Type': "text/plain" },
{ "Content-Type" => "text/plain" },
["Error: not found"]
]
rescue StandardError => e
[
500,
{ 'Content-Type': "text/plain" },
{ "Content-Type" => "text/plain" },
["Error: #{e.message}"]
]
end
Expand All @@ -54,8 +54,8 @@ def self.unauthorized_response
[
401,
{
"Content-Type": "text/plain",
"WWW-Authenticate": "Basic realm=\"Restricted Area\""
"Content-Type" => "text/plain",
"WWW-Authenticate" => "Basic realm=\"Restricted Area\""
},
["Unauthorized"]
]
Expand Down

0 comments on commit 7cc692d

Please sign in to comment.