feat: add Content-Length response header
This commit is contained in:
committed by
Steve Chavez
parent
98fcbedca5
commit
57ef9988a5
@@ -26,7 +26,8 @@ pgErrorCodeMapping = do
|
||||
"details": null,
|
||||
"hint": "Increase the configuration parameter \"max_stack_depth\" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.",
|
||||
"message": "stack depth limit exceeded"}|]
|
||||
{ matchStatus = 500 }
|
||||
{ matchStatus = 500
|
||||
, matchHeaders = ["Content-Length" <:> "217"] }
|
||||
|
||||
context "includes the proxy-status header on the response" $ do
|
||||
it "works with ApiRequest error" $
|
||||
@@ -34,7 +35,8 @@ pgErrorCodeMapping = do
|
||||
`shouldRespondWith`
|
||||
[json| {"code":"PGRST125","details":null,"hint":null,"message":"Invalid path specified in request URL"} |]
|
||||
{ matchStatus = 404
|
||||
, matchHeaders = ["Proxy-Status" <:> "PostgREST; error=PGRST125"]
|
||||
, matchHeaders = [ "Proxy-Status" <:> "PostgREST; error=PGRST125"
|
||||
, "Content-Length" <:> "96" ]
|
||||
}
|
||||
|
||||
it "works with SchemaCache error" $
|
||||
@@ -42,7 +44,8 @@ pgErrorCodeMapping = do
|
||||
`shouldRespondWith`
|
||||
[json| {"code":"PGRST205","details":null,"hint":"Perhaps you meant the table 'test.json_table'","message":"Could not find the table 'test.non_existent_table' in the schema cache"} |]
|
||||
{ matchStatus = 404
|
||||
, matchHeaders = ["Proxy-Status" <:> "PostgREST; error=PGRST205"]
|
||||
, matchHeaders = [ "Proxy-Status" <:> "PostgREST; error=PGRST205"
|
||||
, "Content-Length" <:> "172" ]
|
||||
}
|
||||
|
||||
it "works with Jwt error" $ do
|
||||
@@ -51,7 +54,8 @@ pgErrorCodeMapping = do
|
||||
`shouldRespondWith`
|
||||
[json| {"message":"Expected 3 parts in JWT; got 2","code":"PGRST301","hint":null,"details":null} |]
|
||||
{ matchStatus = 401
|
||||
, matchHeaders = ["Proxy-Status" <:> "PostgREST; error=PGRST301"]
|
||||
, matchHeaders = [ "Proxy-Status" <:> "PostgREST; error=PGRST301"
|
||||
, "Content-Length" <:> "89" ]
|
||||
}
|
||||
|
||||
it "works with raise sqlstate custom error" $
|
||||
@@ -59,7 +63,8 @@ pgErrorCodeMapping = do
|
||||
`shouldRespondWith`
|
||||
[json| {"code":"PT402","details":"Quota exceeded","hint":"Upgrade your plan","message":"Payment Required"} |]
|
||||
{ matchStatus = 402
|
||||
, matchHeaders = ["Proxy-Status" <:> "PostgREST; error=PT402"]
|
||||
, matchHeaders = [ "Proxy-Status" <:> "PostgREST; error=PT402"
|
||||
, "Content-Length" <:> "99" ]
|
||||
}
|
||||
|
||||
it "works with sqlstate PGRST custom error" $
|
||||
@@ -67,5 +72,6 @@ pgErrorCodeMapping = do
|
||||
`shouldRespondWith`
|
||||
[json| {"code":"123","details":"DEF","hint":"XYZ","message":"ABC"} |]
|
||||
{ matchStatus = 332
|
||||
, matchHeaders = ["Proxy-Status" <:> "PostgREST; error=123"]
|
||||
, matchHeaders = [ "Proxy-Status" <:> "PostgREST; error=123"
|
||||
, "Content-Length" <:> "59" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user