Copyright | Copyright (C) 2017- hiratara |
---|---|
License | GPL-3 |
Maintainer | hiratara@cpan.org |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Provides a utility to write server program which can be called via Perl's start_server program using Haskell.
Since the listenAll
function returns a listened Socket
,
please call accept
on it.
import qualified Network.ServerStarter.Socket as Starter import qualified Network.Socket as Socket import qualified Network.Wai as Wai import qualified Network.Wai.Handler.Warp as Warp main :: IO () main = do (socket:_) <- Starter.listenAll Socket.SockAddrInet port _ <- Socket.getSocketName socket let setting = Warp.setPort (fromEnum port) $ Warp.defaultSettings Warp.runSettingsSocket setting socket app app :: Wai.Application app = ...
Then run start_server
and access to http://localhost:12345
.
$ start_server --port 12345 -- stack exec server-starter-warp-example