瀏覽代碼

Fix the Base template

Trevor Elliott 10 年之前
父節點
當前提交
d1c64ff3ba
共有 2 個文件被更改,包括 11 次插入10 次删除
  1. 1 1
      src/Gidl/Backend/Rpc.hs
  2. 10 9
      support/rpc/Base.hs.template

+ 1 - 1
src/Gidl/Backend/Rpc.hs

@@ -57,7 +57,7 @@ rpcBaseModule ns =
   artifactPath (foldr (\ p rest -> p ++ "/" ++ rest) "Server" ns) $
   artifactCabalFileTemplate P.getDataDir "support/rpc/Base.hs.template" env
   where
-  env = [ ("module_prefix", concatMap (++ ".") ns) ]
+  env = [ ("module_path", foldr (\p rest -> p ++ "." ++ rest) "Server" ns) ]
 
 
 -- Utilities -------------------------------------------------------------------

+ 10 - 9
support/rpc/Base.hs.template

@@ -1,13 +1,13 @@
 -- vim: ft=haskell
 
 {-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE OverloadedStrings #-}
 
-module $module_prefix$Base where
+module $module_path$.Base where
 
-import System.Environment
-import System.Console.GetOpt
-import Snap.Http.Server (simpleHttpServe,defaultConfig)
-import Snap.Util.FileServe (serveDirectory)
+import           Snap.Core (Snap,route)
+import qualified Snap.Http.Server as HTTP
+import           Snap.Util.FileServe (serveDirectory)
 
 data Config = Config { cfgPort :: !Int
                        -- ^ The port to run on
@@ -26,11 +26,12 @@ defaultConfig  = Config { cfgPort = 8080, cfgStaticDir = Nothing }
 
 -- | Spawn a snap server, and run the given RPC action.
 runServer :: Config -> Snap () -> IO ()
-runServer Config { .. } serveRpc = simpleHttpServe snapConfig server
+runServer Config { .. } serveRpc =
+  do let snapCfg :: HTTP.Config Snap ()
+         snapCfg  = HTTP.setPort cfgPort HTTP.defaultConfig
+     HTTP.simpleHttpServe snapCfg body
+
   where
-  server =
-    do let snapCfg = setPort cfgPort defaultConfig
-       simpleHttpServe snapCfg body
 
   body =
     do serveRpc