@@ -7,6 +7,7 @@
77module Servant.JQuery.Internal where
88
99import Control.Lens
10+import Data.Monoid
1011import Data.Proxy
1112import GHC.TypeLits
1213import Servant.API
@@ -120,31 +121,31 @@ instance (KnownSymbol sym, HasJQ sublayout)
120121 where str = symbolVal (Proxy :: Proxy sym)
121122
122123instance HasJQ Delete where
123− type JQ Delete = FunctionName -> AjaxReq
124+ type JQ Delete = AjaxReq
124125
125− jqueryFor Proxy req fName =
126− req & funcName .~ fName
126+ jqueryFor Proxy req =
127+ req & funcName %~ ("delete" <>)
127128 & reqMethod .~ "DELETE"
128129
129130instance HasJQ (Get a) where
130− type JQ (Get a) = FunctionName -> AjaxReq
131+ type JQ (Get a) = AjaxReq
131132
132− jqueryFor Proxy req fName =
133− req & funcName .~ fName
133+ jqueryFor Proxy req =
134+ req & funcName %~ ("get" <>)
134135 & reqMethod .~ "GET"
135136
136137instance HasJQ (Post a) where
137− type JQ (Post a) = FunctionName -> AjaxReq
138+ type JQ (Post a) = AjaxReq
138139
139− jqueryFor Proxy req fName =
140− req & funcName .~ fName
140+ jqueryFor Proxy req =
141+ req & funcName %~ ("post" <>)
141142 & reqMethod .~ "POST"
142143
143144instance HasJQ (Put a) where
144− type JQ (Put a) = FunctionName -> AjaxReq
145+ type JQ (Put a) = AjaxReq
145146
146− jqueryFor Proxy req fName =
147− req & funcName .~ fName
147+ jqueryFor Proxy req =
148+ req & funcName %~ ("put" <>)
148149 & reqMethod .~ "PUT"
149150
150151instance (KnownSymbol sym, HasJQ sublayout)
@@ -179,11 +180,10 @@ instance (KnownSymbol sym, HasJQ sublayout)
179180 where str = symbolVal (Proxy :: Proxy sym)
180181
181182instance HasJQ Raw where
182− type JQ Raw = Method -> FunctionName -> AjaxReq
183+ type JQ Raw = Method -> AjaxReq
183184
184− jqueryFor Proxy req method fName =
185+ jqueryFor Proxy req method =
185186 req & reqMethod .~ method
186− & funcName .~ fName
187187
188188instance HasJQ sublayout => HasJQ (ReqBody a :> sublayout) where
189189 type JQ (ReqBody a :> sublayout) = JQ sublayout
@@ -199,5 +199,6 @@ instance (KnownSymbol path, HasJQ sublayout)
199199 jqueryFor Proxy req =
200200 jqueryFor (Proxy :: Proxy sublayout) $
201201 req & reqUrl.path <>~ [Static str]
202+ & funcName %~ (str <>)
202203
203204 where str = symbolVal (Proxy :: Proxy path)