Skip to content

Commit

Permalink
errors: add application/json content type for JSON formatted errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paulRbr committed Nov 25, 2024
1 parent aa080b4 commit bb09786
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions proxy_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ class ProxyServer < Sinatra::Base
).freeze

error JWT::ExpiredSignature do
headers "Content-Type" => "application/json"
halt 401, {error: "Token has expired"}.to_json
end

error JWT::DecodeError do
headers "Content-Type" => "application/json"
halt 401, {error: "Invalid token"}.to_json
end

error JWT::MissingRequiredClaim do |error|
headers "Content-Type" => "application/json"
halt 401, {error: "Token has #{error.to_s.downcase}"}.to_json
end

error do |error|
headers "Content-Type" => "application/json"
halt 502, {error: error.message}.to_json
end

Expand Down

0 comments on commit bb09786

Please sign in to comment.