Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Ibnu Daru Aji
Cirkeltrek
Commits
71a09434
Commit
71a09434
authored
Apr 18, 2018
by
Ibnu Daru Aji
Browse files
created newMain as the new main.
parent
fdd5220c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
7 deletions
+100
-7
Cirkeltrek.cabal
Cirkeltrek.cabal
+20
-1
app/Main.hs
app/Main.hs
+2
-2
package.yaml
package.yaml
+9
-0
routes
routes
+0
-1
src/Application.hs
src/Application.hs
+33
-0
src/Foundation.hs
src/Foundation.hs
+19
-3
src/Settings.hs
src/Settings.hs
+17
-0
No files found.
Cirkeltrek.cabal
View file @
71a09434
...
...
@@ -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
...
...
app/Main.hs
View file @
71a09434
import
Application
()
-- for YesodDispatch instance
import
Application
(
newMain
)
-- for YesodDispatch instance
import
Foundation
import
Yesod.Core
main
::
IO
()
main
=
warp
3000
App
main
=
newMain
package.yaml
View file @
71a09434
...
...
@@ -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.
...
...
routes
deleted
100644 → 0
View file @
fdd5220c
/ HomeR GET
src/Application.hs
View file @
71a09434
{-# 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
src/Foundation.hs
View file @
71a09434
{-# 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
src/Settings.hs
0 → 100644
View file @
71a09434
{-# 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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment