@@ -7,6 +7,7 @@
7module Servant.JQuery.Internal where
7module Servant.JQuery.Internal where
9import Control.Lens
9import Control.Lens
10import Data.Proxy
11import Data.Proxy
11import GHC.TypeLits
12import GHC.TypeLits
12import Servant.API
13import Servant.API
@@ -120,31 +121,31 @@ instance (KnownSymbol sym, HasJQ sublayout)
120 where str = symbolVal (Proxy :: Proxy sym)
121 where str = symbolVal (Proxy :: Proxy sym)
122instance HasJQ Delete where
123instance HasJQ Delete where
123− type JQ Delete = FunctionName -> AjaxReq
124+ type JQ Delete = AjaxReq
125− jqueryFor Proxy req fName =
126+ jqueryFor Proxy req =
126− req & funcName .~ fName
127+ req & funcName %~ ("delete" <>)
127 & reqMethod .~ "DELETE"
128 & reqMethod .~ "DELETE"
129instance HasJQ (Get a) where
130instance HasJQ (Get a) where
130− type JQ (Get a) = FunctionName -> AjaxReq
131+ type JQ (Get a) = AjaxReq
132− jqueryFor Proxy req fName =
133+ jqueryFor Proxy req =
133− req & funcName .~ fName
134+ req & funcName %~ ("get" <>)
134 & reqMethod .~ "GET"
135 & reqMethod .~ "GET"
136instance HasJQ (Post a) where
137instance HasJQ (Post a) where
137− type JQ (Post a) = FunctionName -> AjaxReq
138+ type JQ (Post a) = AjaxReq
139− jqueryFor Proxy req fName =
140+ jqueryFor Proxy req =
140− req & funcName .~ fName
141+ req & funcName %~ ("post" <>)
141 & reqMethod .~ "POST"
142 & reqMethod .~ "POST"
143instance HasJQ (Put a) where
144instance HasJQ (Put a) where
144− type JQ (Put a) = FunctionName -> AjaxReq
145+ type JQ (Put a) = AjaxReq
146− jqueryFor Proxy req fName =
147+ jqueryFor Proxy req =
147− req & funcName .~ fName
148+ req & funcName %~ ("put" <>)
148 & reqMethod .~ "PUT"
149 & reqMethod .~ "PUT"
150instance (KnownSymbol sym, HasJQ sublayout)
151instance (KnownSymbol sym, HasJQ sublayout)
@@ -179,11 +180,10 @@ instance (KnownSymbol sym, HasJQ sublayout)
179 where str = symbolVal (Proxy :: Proxy sym)
180 where str = symbolVal (Proxy :: Proxy sym)
181instance HasJQ Raw where
182instance HasJQ Raw where
182− type JQ Raw = Method -> FunctionName -> AjaxReq
183+ type JQ Raw = Method -> AjaxReq
184− jqueryFor Proxy req method fName =
185+ jqueryFor Proxy req method =
185 req & reqMethod .~ method
186 req & reqMethod .~ method
188instance HasJQ sublayout => HasJQ (ReqBody a :> sublayout) where
188instance HasJQ sublayout => HasJQ (ReqBody a :> sublayout) where
189 type JQ (ReqBody a :> sublayout) = JQ sublayout
189 type JQ (ReqBody a :> sublayout) = JQ sublayout
@@ -199,5 +199,6 @@ instance (KnownSymbol path, HasJQ sublayout)
199 jqueryFor Proxy req =
199 jqueryFor Proxy req =
200 jqueryFor (Proxy :: Proxy sublayout) $
200 jqueryFor (Proxy :: Proxy sublayout) $
201 req & reqUrl.path <>~ [Static str]
201 req & reqUrl.path <>~ [Static str]
202+ & funcName %~ (str <>)
203 where str = symbolVal (Proxy :: Proxy path)
204 where str = symbolVal (Proxy :: Proxy path)