Permalink
Browse files

Merge pull request #7 from drozzy/master

Fixed the example1 to work with snap 0.9
  • Loading branch information...
2 parents 78c6b06 + 3aeec9a commit 014fc1245bc034c64b0df8ff3813dd63af8adade @Palmik committed Oct 4, 2012
View
@@ -1 +1,3 @@
-*.*~
+*.*~
+dist
+*.log
@@ -0,0 +1 @@
+log
@@ -7,7 +7,7 @@ license-file: LICENSE
author: Petr Pilař
maintainer: jondoe@example.com
build-type: Simple
-cabal-version: >= 1.6
+cabal-version: >= 1.2
homepage: example.com
category: Web
@@ -22,15 +22,16 @@ Executable snaplet-mongodb-minimalistic-example1
Build-depends:
base >= 4 && < 5,
bytestring >= 0.9.1 && < 0.10,
- data-lens >= 2.0.1 && < 2.1,
+ data-lens >= 2.0.1 && < 2.11,
data-lens-template >= 2.1 && < 2.2,
- heist >= 0.7 && < 0.8,
+ heist >= 0.8 && < 0.9,
mtl >= 2 && < 3,
- snap == 0.7.*,
- snap-core == 0.7.*,
- snap-server == 0.7.*,
+ snap == 0.9.*,
+ snap-core == 0.9.*,
+ snap-server == 0.9.*,
+ snap-loader-static == 0.9.*,
text >= 0.11 && < 0.12,
- xmlhtml == 0.1.*,
+ xmlhtml >= 0.1,
snaplet-mongodb-minimalistic,
mongoDB,
utf8-string
No changes.
No changes.
@@ -10,17 +10,15 @@ import qualified Data.Text as T
import Snap.Http.Server
import Snap.Snaplet
import Snap.Core
-
-import Application
-
+import Snap.Snaplet.Config
import System.IO
import Site
#ifdef DEVELOPMENT
-import Snap.Loader.Devel
+import Snap.Loader.Dynamic
#else
-import Snap.Loader.Prod
+import Snap.Loader.Static
#endif
main :: IO ()
@@ -32,7 +30,7 @@ main = do
_ <- try $ httpServe conf $ site :: IO (Either SomeException ())
cleanup
-getConf :: IO (Config Snap ())
+getConf :: IO (Config Snap AppConfig)
getConf = commandLineConfig defaultConfig
@@ -49,8 +47,8 @@ getConf = commandLineConfig defaultConfig
--
-- This sample doesn't actually use the config passed in, but more
-- sophisticated code might.
-getActions :: Config Snap () -> IO (Snap (), IO ())
-getActions _ = do
- (msgs, site, cleanup) <- runSnaplet app
+getActions :: Config Snap AppConfig -> IO (Snap (), IO ())
+getActions conf = do
+ (msgs, site, cleanup) <- runSnaplet (appEnvironment =<< getOther conf) app
hPutStrLn stderr $ T.unpack msgs
return (site, cleanup)
@@ -44,12 +44,12 @@ routes :: [(ByteString, Handler App App ())]
routes = [ ("/", method POST indexHandler)
, ("/", indexView)
, ("", with heist heistServe)
- , ("", serveDirectory "resources/static")
+ , ("", serveDirectory "static")
]
app :: SnapletInit App App
app = makeSnaplet "app" "An snaplet example application." Nothing $ do
- h <- nestSnaplet "heist" heist $ heistInit "resources/templates"
+ h <- nestSnaplet "heist" heist $ heistInit "templates"
d <- nestSnaplet "database" database $ mongoDBInit 10 (host "127.0.0.1") "Snaplet-MongoDB"
addRoutes routes
return $ App h d

0 comments on commit 014fc12

Please sign in to comment.