@@ -1,16 +1,16 @@
11module Servant.JS.Angular where
22
3−import Servant.JS.Internal
4−import Control.Lens
5−import Data.List
6−import Data.Monoid
3+import Control.Lens
4+import Data.List
5+import Data.Monoid
6+import Servant.JS.Internal
77
88-- | Options specific to the angular code generator
99data AngularOptions = AngularOptions
1010 { serviceName :: String -- ^ When generating code with wrapInService,
1111 -- name of the service to generate
12− , prologue :: String -> String -> String -- ^ beginning of the service definition
13− , epilogue :: String -- ^ end of the service definition
12+ , prologue :: String -> String -> String -- ^ beginning of the service definition
13+ , epilogue :: String -- ^ end of the service definition
1414 }
1515
1616-- | Default options for the Angular codegen. Used by 'wrapInService'.
@@ -31,7 +31,7 @@ angularService ngOpts = angularServiceWith ngOpts defCommonGeneratorOptions
3131-- | Instead of simply generating top level functions, generates a service instance
3232-- on which your controllers can depend to access your API
3333angularServiceWith :: AngularOptions -> CommonGeneratorOptions -> JavaScriptGenerator
34−angularServiceWith ngOpts opts reqs =
34+angularServiceWith ngOpts opts reqs =
3535 prologue ngOpts svc mName
3636 <> intercalate "," (map generator reqs) <>
3737 epilogue ngOpts
@@ -54,7 +54,7 @@ angularWith ngopts opts = intercalate "\n\n" . map (generateAngularJSWith ngopts
5454-- | js codegen using $http service from Angular using default options
5555generateAngularJS :: AngularOptions -> AjaxReq -> String
5656generateAngularJS ngOpts = generateAngularJSWith ngOpts defCommonGeneratorOptions
57−
57+
5858-- | js codegen using $http service from Angular
5959generateAngularJSWith :: AngularOptions -> CommonGeneratorOptions -> AjaxReq -> String
6060generateAngularJSWith ngOptions opts req = "\n" <>
@@ -74,7 +74,7 @@ generateAngularJSWith ngOptions opts req = "\n" <>
7474 ++ map (view argName) queryparams
7575 ++ body
7676 ++ map (toValidFunctionName . (<>) "header" . headerArgName) hs
77−
77+
7878 -- If we want to generate Top Level Function, they must depend on
7979 -- the $http service, if we generate a service, the functions will
8080 -- inherit this dependency from the service
@@ -118,13 +118,13 @@ generateAngularJSWith ngOptions opts req = "\n" <>
118118 else (moduleName opts) <> "."
119119 where
120120 hasNoModule = null (moduleName opts)
121−
121+
122122 hasService = not $ null (serviceName ngOptions)
123−
123+
124124 fsep = if hasService then ":" else " ="
125−
125+
126126 fname = namespace <> (functionNameBuilder opts $ req ^. funcName)
127−
127+
128128 method = req ^. reqMethod
129129 url = if url' == "'" then "'/'" else url'
130130 url' = "'"