@@ -62,7 +62,6 @@ import Foreign.Store (Store (..), lookupStore, readStore, storeAction, withStore
62
62
import GHC.Generics (Generic )
63
63
import GHC.Word (Word32 )
64
64
import Network.HTTP.Types (Header , Method , QueryItem , hCacheControl , methodPost , status200 , status404 )
65
- import Network.Wai (pathInfo )
66
65
import Network.Wai qualified as Wai
67
66
import Network.Wai.Handler.Warp qualified as Warp
68
67
import Network.Wai.Middleware.Static as Static (CacheContainer , CachingStrategy (.. ), Options (.. ), addBase )
@@ -91,46 +90,13 @@ run = do
91
90
cache <- clientCache
92
91
Warp. run port $
93
92
Static. staticPolicyWithOptions cache (addBase " client/dist" ) $
94
- Static. staticPolicy (addBase " examples/static" ) $ \ req -> do
95
- let doc = case pathInfo req of
96
- " todoscss" : _ -> toDocumentTodosCSS
97
- _ -> toDocument
98
- (app doc users count) req
99
-
100
- -- Use the embedded version for real applications (see basicDocument).
101
- -- The link to /hyperbole.js here is just to make local development easier
102
- toDocument :: BL. ByteString -> BL. ByteString
103
- toDocument cnt =
104
- [i |<html>
105
- <head>
106
- <title>Hyperbole Examples</title>
107
- <meta httpEquiv="Content-Type" content="text/html" charset="UTF-8">
108
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
109
- <script type="text/javascript" src="/hyperbole.js"></script>
110
- <script type="text/javascript" src="/custom.js"></script>
111
- <style type="text/css">#{cssResetEmbed}</style>
112
- <style type="text/css">body { background-color: \#d3dceb }</style>
113
- </head>
114
- <body>#{cnt}</body>
115
- </html>|]
116
-
117
- toDocumentTodosCSS :: BL. ByteString -> BL. ByteString
118
- toDocumentTodosCSS cnt =
119
- [i |<html>
120
- <head>
121
- <title>Todo MVC</title>
122
- <script type="text/javascript">#{scriptEmbed}</script>
123
-
124
- <link href="https://cdn.jsdelivr.net/npm/
[email protected] /index.min.css"
125
- rel="stylesheet">
126
- </head>
127
- <body>#{cnt}</body>
128
- </html>|]
93
+ Static. staticPolicy (addBase " examples/static" ) $
94
+ app users count
129
95
130
- app :: ( BL. ByteString -> BL. ByteString ) -> UserStore -> TVar Int -> Application
131
- app doc users count = do
96
+ app :: UserStore -> TVar Int -> Application
97
+ app users count = do
132
98
liveApp
133
- doc
99
+ toDocument
134
100
(runApp . routeRequest $ router)
135
101
where
136
102
runApp :: (Hyperbole :> es , IOE :> es ) => Eff (GenRandom : Concurrent : Debug : Users : Todos : es ) a -> Eff es a
@@ -178,6 +144,23 @@ app doc users count = do
178
144
hello Redirected = do
179
145
pure $ exampleLayout RedirectNow $ el (pad 10 ) " You were redirected"
180
146
147
+ -- Use the embedded version for real applications (see basicDocument).
148
+ -- The link to /hyperbole.js here is just to make local development easier
149
+ toDocument :: BL. ByteString -> BL. ByteString
150
+ toDocument cnt =
151
+ [i |<html>
152
+ <head>
153
+ <title>Hyperbole Examples</title>
154
+ <meta httpEquiv="Content-Type" content="text/html" charset="UTF-8">
155
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
156
+ <script type="text/javascript" src="/hyperbole.js"></script>
157
+ <script type="text/javascript" src="/custom.js"></script>
158
+ <style type="text/css">#{cssResetEmbed}</style>
159
+ <style type="text/css">body { background-color: \#d3dceb }</style>
160
+ </head>
161
+ <body>#{cnt}</body>
162
+ </html>|]
163
+
181
164
{- | Made for local development
182
165
-
183
166
- ghcid --setup=Main.update --command="cabal repl exe:examples lib:hyperbole test" --run=Main.update --warnings
0 commit comments