on master help sign in
Listen port detection
commitf8dd608803dbc59b798cf008a8daf270da5fd8b4 authorilyakooo0 <ilyakooo0@gmail.com> dateTue 22 Jan 2019, 17:32 (8 years ago) parentbcbeab9
2 files changed+8−2
app/Main.hs+4−1 src/Lib.hs+4−1
app/Main.hs+4−1
@@ -2,9 +2,12 @@ module Main where
22
33import Network.Wai.Handler.Warp (run)
44import Servant.Server (serve)
5+import System.Environment
56import Lib
67
78main :: IO ()
89main = do
10+ env <- getEnvironment
11+ let port = maybe 2000 read $ lookup "PORT" env
912 srv <- createServer
10− run 2000 $ serve server srv
13+ run port $ serve server srv
src/Lib.hs+4−1
@@ -38,7 +38,10 @@ type API = "users" :> Capture "id" UserId :> Get '[JSON] User
3838createServer :: IO (Server API)
3939createServer = do
4040 cfg <- createConfig
41− atomically $ newUser cfg "Kostya" "Designer"
41+ atomically $ newUser cfg "Kostya" "Designerovich"
42+ atomically $ newUser cfg "Anna" "Androidovna"
43+ atomically $ newUser cfg "Darya" "Aiphonovna"
44+ atomically $ newUser cfg "Ilya" "Serverovich"
4245 return $ hoistServer server (createApp cfg) serverAPI
4346
4447server :: Proxy API