on master help sign in
Merge pull request #172 from freezeboy/add-url-prefix

Add urlPrefix to CommonGeneratorOptions

commit4ff9697ed720cd1f9b8c8b44b12f8918c9c3d201 authorAlp Mestanogullari <alpmestan@gmail.com> dateTue 28 Jul 2015, 15:53 (11 years ago) parenteed8acd8b927e7
4 files changed+6
servant-js/src/Servant/JS/Angular.hs+1 servant-js/src/Servant/JS/Internal.hs+3 servant-js/src/Servant/JS/JQuery.hs+1 servant-js/src/Servant/JS/Vanilla.hs+1
servant-js/src/Servant/JS/Angular.hs+1
@@ -128,6 +128,7 @@ generateAngularJSWith ngOptions opts req = "\n" <>
128128 method = req ^. reqMethod
129129 url = if url' == "'" then "'/'" else url'
130130 url' = "'"
131+ ++ urlPrefix opts
131132 ++ urlArgs
132133 ++ queryArgs
133134
servant-js/src/Servant/JS/Internal.hs+3
@@ -34,6 +34,7 @@ data CommonGeneratorOptions = CommonGeneratorOptions
3434 , successCallback :: String -- ^ name of the callback parameter when the request was successful
3535 , errorCallback :: String -- ^ name of the callback parameter when the request reported an error
3636 , 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
3738 }
3839
3940-- | Default options.
@@ -45,6 +46,7 @@ data CommonGeneratorOptions = CommonGeneratorOptions
4546-- > , successCallback = "onSuccess"
4647-- > , errorCallback = "onError"
4748-- > , moduleName = ""
49+-- > , urlPrefix = ""
4850-- > }
4951-- @
5052defCommonGeneratorOptions :: CommonGeneratorOptions
@@ -55,6 +57,7 @@ defCommonGeneratorOptions = CommonGeneratorOptions
5557 , successCallback = "onSuccess"
5658 , errorCallback = "onError"
5759 , moduleName = ""
60+ , urlPrefix = ""
5861 }
5962
6063type Arg = String
servant-js/src/Servant/JS/JQuery.hs+1
@@ -81,6 +81,7 @@ generateJQueryJSWith opts req = "\n" <>
8181 method = req ^. reqMethod
8282 url = if url' == "'" then "'/'" else url'
8383 url' = "'"
84+ ++ urlPrefix opts
8485 ++ urlArgs
8586 ++ queryArgs
8687
servant-js/src/Servant/JS/Vanilla.hs+1
@@ -88,6 +88,7 @@ generateVanillaJSWith opts req = "\n" <>
8888 method = req ^. reqMethod
8989 url = if url' == "'" then "'/'" else url'
9090 url' = "'"
91+ ++ urlPrefix opts
9192 ++ urlArgs
9293 ++ queryArgs
9394