Configurable port
This commit is contained in:
		@@ -18,7 +18,8 @@ data Store = Filestore { path :: Text }
 | 
				
			|||||||
           deriving (Show, Generic)
 | 
					           deriving (Show, Generic)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
data Config = Config { database :: Pg
 | 
					data Config = Config { database :: Pg
 | 
				
			||||||
                     , store :: Store }
 | 
					                     , store :: Store
 | 
				
			||||||
 | 
					                     , port :: Integer }
 | 
				
			||||||
            deriving (Show, Generic)
 | 
					            deriving (Show, Generic)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
instance Interpret Pg
 | 
					instance Interpret Pg
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ module Main where
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import           ClassyPrelude
 | 
					import           ClassyPrelude
 | 
				
			||||||
import           Configuration
 | 
					import           Configuration
 | 
				
			||||||
import           Control.Lens              (view)
 | 
					import           Control.Lens              (view, to)
 | 
				
			||||||
import           Data.Generics.Product
 | 
					import           Data.Generics.Product
 | 
				
			||||||
import           Data.Pool                 (createPool)
 | 
					import           Data.Pool                 (createPool)
 | 
				
			||||||
import           Database.Selda.PostgreSQL (PGConnectInfo (..), pgOpen,
 | 
					import           Database.Selda.PostgreSQL (PGConnectInfo (..), pgOpen,
 | 
				
			||||||
@@ -21,7 +21,7 @@ import           Types
 | 
				
			|||||||
import System.Environment (getEnvironment)
 | 
					import System.Environment (getEnvironment)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
defaultMain :: App -> IO ()
 | 
					defaultMain :: App -> IO ()
 | 
				
			||||||
defaultMain = run 8080 . server
 | 
					defaultMain app = run (view (field @"config" . field @"port" . to fromIntegral) app) $ server app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
withApp :: Config -> (App -> IO ()) -> IO ()
 | 
					withApp :: Config -> (App -> IO ()) -> IO ()
 | 
				
			||||||
withApp config f = do
 | 
					withApp config f = do
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,4 +4,5 @@
 | 
				
			|||||||
             , database : Text
 | 
					             , database : Text
 | 
				
			||||||
             , migrations : Text }
 | 
					             , migrations : Text }
 | 
				
			||||||
, store : < Filestore : { path : Text } | IPFS : { common : Text } >
 | 
					, store : < Filestore : { path : Text } | IPFS : { common : Text } >
 | 
				
			||||||
 | 
					, port : Integer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user