Commit 71a09434 authored by Ibnu Daru Aji's avatar Ibnu Daru Aji

created newMain as the new main.

parent fdd5220c
......@@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: b4baa8144520c126d4e5943935b64fb2042530ae57acc39849371b5063014adf
-- hash: 130568e8906ba78e7d3abb16ae293016701085b7a7df3d7355a3220b9de36158
name: Cirkeltrek
version: 0.0.0
......@@ -14,6 +14,7 @@ library
Application
Foundation
Home
Settings
other-modules:
Paths_Cirkeltrek
hs-source-dirs:
......@@ -23,6 +24,15 @@ library
, classy-prelude
, classy-prelude-yesod
, esqueleto
, monad-logger
, persistent
, persistent-postgresql
, persistent-template
, template-haskell
, wai
, wai-extra
, wai-logger
, warp
, yesod-auth
, yesod-auth-hashdb
, yesod-core
......@@ -42,6 +52,15 @@ executable Cirkeltrek
, classy-prelude
, classy-prelude-yesod
, esqueleto
, monad-logger
, persistent
, persistent-postgresql
, persistent-template
, template-haskell
, wai
, wai-extra
, wai-logger
, warp
, yesod-auth
, yesod-auth-hashdb
, yesod-core
......
import Application () -- for YesodDispatch instance
import Application (newMain) -- for YesodDispatch instance
import Foundation
import Yesod.Core
main :: IO ()
main = warp 3000 App
main = newMain
......@@ -6,10 +6,19 @@ dependencies:
- classy-prelude
- classy-prelude-yesod
- esqueleto
- monad-logger
- persistent
- persistent-template
- persistent-postgresql
- template-haskell
- yesod-auth
- yesod-auth-hashdb
- yesod-core
- yesod-form
- wai
- wai-extra
- wai-logger
- warp
# The library contains all of our application code. The executable
# defined below is just a thin wrapper.
......
/ HomeR GET
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Application where
import Control.Monad
import Control.Monad.Logger
import Foundation
import Language.Haskell.TH.Syntax
import Network.Wai.Handler.Warp
import Yesod.Core
import Home
import Settings (ApplicationSettings (..))
mkYesodDispatch "App" resourcesApp
warpSettings :: App -> Settings
warpSettings app =
setPort (appPort $ appSettings app) $
setHost (appHost $ appSettings app) $
setOnException
(\_req exception ->
when (defaultShouldDisplayException exception) $
messageLoggerSource
app
(appLogger app)
$(qLocation >>= liftLoc)
"yesod"
LevelError
(toLogStr $ "Exception from warp: " ++ show exception))
defaultSettings
makeApplication :: App -> IO Application
makeApplication app = do
commonapp <- toWaiApp app
return $ defaultMiddlewaresNoLogging commonapp
newMain :: IO ()
newMain = do
let app = undefined
commonapp <- makeApplication app
runSettings (warpSettings app) commonapp
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
module Foundation where
import Database.Persist.Sql
import Yesod.Core
import Yesod.Core.Types
import Settings
data App = App
{ appSettings :: ApplicationSettings
, appConnectionPool :: ConnectionPool
, appLogger :: Logger
}
mkYesodData "App" $(parseRoutesFile "routes")
mkYesodData
"App"
[parseRoutes|
/ HomeR GET
|]
instance Yesod App
instance Yesod App where
approot = ApprootRequest $ \app req ->
case appRoot $ appSettings app of
Nothing -> getApprootText guessApproot app req
Just root -> root
{-# LANGUAGE CPP #-}
module Settings where
import ClassyPrelude.Yesod
import Database.Persist.Postgresql
import Network.Wai.Handler.Warp
data ApplicationSettings = ApplicationSettings
{ appStaticDir :: String
, appRoot :: Maybe Text
, appHost :: HostPreference
, appPort :: Int
, appReloadTemplate :: Bool
, appMutableStatic :: Bool
, appSkipCombining :: Bool
, appDetailedRequestLogging :: Bool
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment