Created
November 11, 2014 10:56
-
-
Save soenkehahn/22cf37a65d5e425895e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds, TypeOperators #-} | |
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
module Kraken.Daemon where | |
import Control.Monad.Trans.Either | |
import Data.Proxy | |
import Network.Wai | |
import Network.Wai.Handler.Warp.Run | |
import Servant | |
import Kraken.Store | |
import Kraken.Web.TargetGraph | |
-- * API definition | |
type DaemonApi = | |
"targetGraph" :> Get TargetGraph | |
:<|> Get () | |
daemonApi :: Proxy DaemonApi | |
daemonApi = Proxy | |
-- * server implementation | |
runDaemon :: Port -> Store -> IO () | |
runDaemon port store = runWarp port (daemon store) | |
daemon :: Store -> Application | |
daemon store = serve daemonApi (server store) | |
server :: Store -> Server DaemonApi | |
server store = | |
(return $ toTargetGraph $ graph store) :<|> | |
left (404, "not found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment