@@ -19,6 +19,7 @@ import Data.Variant (Variant)
19import Data.Variant as Variant
19import Data.Variant as Variant
20import Prim.Row (class Cons)
20import Prim.Row (class Cons)
21import Prim.RowList as RL
21import Prim.RowList as RL
22+import Prim.TypeError (class Fail, Text, Above)
22import Type.Proxy (Proxy(..))
23import Type.Proxy (Proxy(..))
23import Unsafe.Coerce (unsafeCoerce)
24import Unsafe.Coerce (unsafeCoerce)
@@ -70,6 +71,43 @@ instance toResponseRLBodyHeaders ::
70else instance toResponseRLBodyOnly ::
71else instance toResponseRLBodyOnly ::
71 ToResponseRL (RL.Cons "body" body RL.Nil) () body
72 ToResponseRL (RL.Cons "body" body RL.Nil) () body
74+-- Invalid record structure: has fields other than "body" and "headers"
75+else instance toResponseRLInvalid ::
78+ (Text "Invalid response record structure.")
82+ (Text "Response records must contain ONLY:")
84+ (Text " • body :: YourBodyType (required)")
86+ (Text " • headers :: Record (...) (optional)")
90+ (Text "Valid examples:")
92+ (Text " { body: user }")
94+ (Text " { body: user, headers: { \"Location\": \"/users/123\" } }")
97+ (Text "Do not include 'status', 'statusCode', or other fields.")
109+ ToResponseRL rl headers body
73--------------------------------------------------------------------------------
111--------------------------------------------------------------------------------
74-- Response Construction Helpers
112-- Response Construction Helpers
75--------------------------------------------------------------------------------
113--------------------------------------------------------------------------------