@@ -33,6 +33,9 @@ type CustomAuthAPI = "something" :> Authorization "Basic" String
3333type CustomHeaderAPI = "something" :> MyLovelyHorse String
3434 :> Get Int
3535
36+type CustomHeaderAPI2 = "something" :> WhatsForDinner String
37+ :> Get Int
38+
3639headerHandlingProxy :: Proxy HeaderHandlingAPI
3740headerHandlingProxy = Proxy
3841
@@ -42,6 +45,9 @@ customAuthProxy = Proxy
4245customHeaderProxy :: Proxy CustomHeaderAPI
4346customHeaderProxy = Proxy
4447
48+customHeaderProxy2 :: Proxy CustomHeaderAPI2
49+customHeaderProxy2 = Proxy
50+
4551spec :: Spec
4652spec = describe "Servant.JQuery"
4753 generateJSSpec
@@ -79,3 +85,10 @@ generateJSSpec = describe "generateJS" $ do
7985 parseFromString jsText `shouldSatisfy` isRight
8086 jsText `shouldContain` "headerXMyLovelyHorse"
8187 jsText `shouldContain` "headers: { \"X-MyLovelyHorse\": \"I am good friends with \" + headerXMyLovelyHorse }\n"
88+
89+ it "should handle complex, custom HTTP headers (template replacement)" $ do
90+ let jsText = generateJS $ jquery customHeaderProxy2
91+ print jsText
92+ parseFromString jsText `shouldSatisfy` isRight
93+ jsText `shouldContain` "headerXWhatsForDinner"
94+ jsText `shouldContain` "headers: { \"X-WhatsForDinner\": \"I would like \" + headerXWhatsForDinner + \" with a cherry on top.\" }\n"