Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A web service for Swarm.
The service can be started using the `--port 5357` command line argument,
or through the REPL by calling demoWeb
.
Once running, here are the available endpoints:
- /robots : return the list of robots
- robotID : return a single robot identified by its id
Missing endpoints:
- TODO: #625 run endpoint to load definitions
- TODO: #493 export the whole game state
Synopsis
- type SwarmApi = ("robots" :> Get '[JSON] [Robot]) :<|> ("robot" :> (Capture "id" Int :> Get '[JSON] (Maybe Robot)))
- mkApp :: IORef GameState -> Server SwarmApi
- webMain :: Maybe (MVar (Either String ())) -> Port -> IORef GameState -> IO ()
- defaultPort :: Port
- startWebThread :: Maybe Port -> IORef GameState -> IO (Either String Port)
Documentation
type SwarmApi = ("robots" :> Get '[JSON] [Robot]) :<|> ("robot" :> (Capture "id" Int :> Get '[JSON] (Maybe Robot))) Source #
defaultPort :: Port Source #
startWebThread :: Maybe Port -> IORef GameState -> IO (Either String Port) Source #
Attempt to start a web thread on the requested port, or a default
one if none is requested (or don't start a web thread if the
requested port is 0). If an explicit port was requested, fail if
startup doesn't work. Otherwise, ignore the failure. In any
case, return a Maybe Port
value representing whether a web
server is actually running, and if so, what port it is on.