git.iko.soy/typeable/servant
on master help sign in
Add urlPrefix to CommonGeneratorOptions
8b927e7Freezeboy
servant-js/src/Servant/JS/Angular.hs+1
@@ -128,6 +128,7 @@ generateAngularJSWith ngOptions opts req = "\n" <>
128 method = req ^. reqMethod
128 method = req ^. reqMethod
129 url = if url' == "'" then "'/'" else url'
129 url = if url' == "'" then "'/'" else url'
130 url' = "'"
130 url' = "'"
131+ ++ urlPrefix opts
131 ++ urlArgs
132 ++ urlArgs
132 ++ queryArgs
133 ++ queryArgs
133
134
servant-js/src/Servant/JS/Internal.hs+3
@@ -34,6 +34,7 @@ data CommonGeneratorOptions = CommonGeneratorOptions
34 , successCallback :: String -- ^ name of the callback parameter when the request was successful
34 , successCallback :: String -- ^ name of the callback parameter when the request was successful
35 , errorCallback :: String -- ^ name of the callback parameter when the request reported an error
35 , errorCallback :: String -- ^ name of the callback parameter when the request reported an error
36 , moduleName :: String -- ^ namespace on which we define the js function (empty mean local var)
36 , moduleName :: String -- ^ namespace on which we define the js function (empty mean local var)
37+ , urlPrefix :: String -- ^ a prefix we should add to the Url in the JS codegen
37 }
38 }
38
39
39-- | Default options.
40-- | Default options.
@@ -45,6 +46,7 @@ data CommonGeneratorOptions = CommonGeneratorOptions
45-- > , successCallback = "onSuccess"
46-- > , successCallback = "onSuccess"
46-- > , errorCallback = "onError"
47-- > , errorCallback = "onError"
47-- > , moduleName = ""
48-- > , moduleName = ""
49+-- > , urlPrefix = ""
48-- > }
50-- > }
49-- @
51-- @
50defCommonGeneratorOptions :: CommonGeneratorOptions
52defCommonGeneratorOptions :: CommonGeneratorOptions
@@ -55,6 +57,7 @@ defCommonGeneratorOptions = CommonGeneratorOptions
55 , successCallback = "onSuccess"
57 , successCallback = "onSuccess"
56 , errorCallback = "onError"
58 , errorCallback = "onError"
57 , moduleName = ""
59 , moduleName = ""
60+ , urlPrefix = ""
58 }
61 }
59
62
60type Arg = String
63type Arg = String
servant-js/src/Servant/JS/JQuery.hs+1
@@ -81,6 +81,7 @@ generateJQueryJSWith opts req = "\n" <>
81 method = req ^. reqMethod
81 method = req ^. reqMethod
82 url = if url' == "'" then "'/'" else url'
82 url = if url' == "'" then "'/'" else url'
83 url' = "'"
83 url' = "'"
84+ ++ urlPrefix opts
84 ++ urlArgs
85 ++ urlArgs
85 ++ queryArgs
86 ++ queryArgs
86
87
servant-js/src/Servant/JS/Vanilla.hs+1
@@ -88,6 +88,7 @@ generateVanillaJSWith opts req = "\n" <>
88 method = req ^. reqMethod
88 method = req ^. reqMethod
89 url = if url' == "'" then "'/'" else url'
89 url = if url' == "'" then "'/'" else url'
90 url' = "'"
90 url' = "'"
91+ ++ urlPrefix opts
91 ++ urlArgs
92 ++ urlArgs
92 ++ queryArgs
93 ++ queryArgs
93
94