gameAllMovesHandler :: Handler b LokaService ()
gameAllMovesHandler = do
  gameId <- getParam "gameId"
  colorParam <- getQueryParam "color"
  maybe (writeBS $ jsonError "Invalid game ID") (\gameIdValid -> do
    maybe (writeBS $ jsonError "Invalid color") (\colorValid -> do
      gameState <- liftIO . getGameState $ ((read $ B.unpack gameIdValid) :: Integer)
      writeBS $ LB.toStrict $ encode $ allPossibleMoves
        (collapseGameState gameState)
        (read (B.unpack colorValid) :: PieceColor)) colorParam) gameId

------------------------------------------------------------------------------
-- | Called by Snap to create the Loka service snaplet
gameAllMovesHandler :: Handler b LokaService ()
gameAllMovesHandler = do
  gameId <- getParam "gameId"
  colorParam <- getQueryParam "color"
  maybe (writeBS $ jsonError "Invalid game ID") (\gameIdValid -> do
    maybe (writeBS $ jsonError "Invalid color") (\colorValid -> do
      gameState <- liftIO . getGameState $ ((read $ B.unpack gameIdValid) :: Integer)
      writeBS $ LB.toStrict $ encode $ allPossibleMoves
        (collapseGameState gameState)
        (read (B.unpack colorValid) :: PieceColor)) colorParam) gameId

------------------------------------------------------------------------------
-- | Called by Snap to create the Loka service snaplet
gameAllMovesHandler = do
  gameId <- getParam "gameId"
  colorParam <- getQueryParam "color"
  maybe (writeBS $ jsonError "Invalid game ID") (\gameIdValid -> do
    maybe (writeBS $ jsonError "Invalid color") (\colorValid -> do
      gameState <- liftIO . getGameState $ ((read $ B.unpack gameIdValid) :: Integer)
      writeBS $ LB.toStrict $ encode $ allPossibleMoves
        (collapseGameState gameState)
        (read (B.unpack colorValid) :: PieceColor)) colorParam) gameId

------------------------------------------------------------------------------
-- | Called by Snap to create the Loka service snaplet