git.iko.soy/typeable/servant
on master help sign in
More PR5 fixes
ad900cdJulian K. Arni
CHANGELOG.md+1
@@ -2,6 +2,7 @@
2---
2---
3* Extend `HeaderArg` to support more advanced HTTP header handling (https://github.com/haskell-servant/servant-jquery/pull/6)
3* Extend `HeaderArg` to support more advanced HTTP header handling (https://github.com/haskell-servant/servant-jquery/pull/6)
4* Support content-type aware combinators (but require that endpoints support JSON)
4* Support content-type aware combinators (but require that endpoints support JSON)
5+* Add support for Matrix params (https://github.com/haskell-servant/servant-jquery/pull/11)
5
6
60.2.2
70.2.2
7-----
8-----
src/Servant/JQuery.hs+3−2
@@ -46,7 +46,7 @@ generateJS req = "\n" <>
46 ++ body
46 ++ body
47 ++ map (toValidFunctionName . (<>) "header" . headerArgName) hs
47 ++ map (toValidFunctionName . (<>) "header" . headerArgName) hs
48 ++ ["onSuccess", "onError"]
48 ++ ["onSuccess", "onError"]
49−
49+
50 captures = map captureArg
50 captures = map captureArg
51 . filter isCapture
51 . filter isCapture
52 $ req ^. reqUrl.path
52 $ req ^. reqUrl.path
@@ -76,7 +76,8 @@ generateJS req = "\n" <>
76
76
77 fname = req ^. funcName
77 fname = req ^. funcName
78 method = req ^. reqMethod
78 method = req ^. reqMethod
79− url = "'"
79+ url = if url' == "'" then "'/'" else url'
80+ url' = "'"
80 ++ urlArgs
81 ++ urlArgs
81 ++ queryArgs
82 ++ queryArgs
82
83
src/Servant/JQuery/Internal.hs+1−20
@@ -31,25 +31,6 @@ data SegmentType = Static String -- ^ a static path segment. like "/foo"
31 | Cap Arg -- ^ a capture. like "/:userid"
31 | Cap Arg -- ^ a capture. like "/:userid"
32 deriving (Eq, Show)
32 deriving (Eq, Show)
33
33
34−isCapture :: Segment -> Bool
35−isCapture (Cap _) = True
36−isCapture _ = False
37−
38−captureArg :: Segment -> Arg
39−captureArg (Cap s) = s
40−captureArg _ = error "captureArg called on non capture"
41−
42−jsSegments :: [Segment] -> String
43−jsSegments [] = "/'"
44−jsSegments [x] = "/" ++ segmentToStr x False
45−jsSegments (x:xs) = "/" ++ segmentToStr x True ++ jsSegments xs
46−
47−segmentToStr :: Segment -> Bool -> String
48−segmentToStr (Static s) notTheEnd =
49− if notTheEnd then s else s ++ "'"
50−segmentToStr (Cap s) notTheEnd =
51− "' + encodeURIComponent(" ++ s ++ if notTheEnd then ") + '" else ")"
52−
53type Path = [Segment]
34type Path = [Segment]
54
35
55data ArgType =
36data ArgType =
@@ -305,7 +286,7 @@ instance (KnownSymbol sym, HasJQ sublayout)
305
286
306 jqueryFor Proxy req =
287 jqueryFor Proxy req =
307 jqueryFor (Proxy :: Proxy sublayout) $
288 jqueryFor (Proxy :: Proxy sublayout) $
308− req & reqUrl.path._last.matrix <>~ [QueryArg str Normal]
289+ req & reqUrl.path._last.matrix <>~ [QueryArg strArg Normal]
309
290
310 where str = symbolVal (Proxy :: Proxy sym)
291 where str = symbolVal (Proxy :: Proxy sym)
311 strArg = str ++ "Value"
292 strArg = str ++ "Value"
test/Servant/JQuerySpec.hs−1
@@ -13,7 +13,6 @@ import Language.ECMAScript3.Parser (parseFromString)
13import Test.Hspec
13import Test.Hspec
14
14
15import Servant.API
15import Servant.API
16−import Servant.API.ContentTypes
17import Servant.JQuery
16import Servant.JQuery
18import Servant.JQuerySpec.CustomHeaders
17import Servant.JQuerySpec.CustomHeaders
19
18