From c1988345690b9da7a82020ff72542860fcb1d68a Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 16 Feb 2022 16:57:49 +0100 Subject: server: add mapservice GET endpoint --- server/Main.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server/Main.hs') diff --git a/server/Main.hs b/server/Main.hs index 0d5dfd6..8b41c92 100644 --- a/server/Main.hs +++ b/server/Main.hs @@ -19,9 +19,9 @@ import Control.Concurrent.STM.TQueue (TQueue, newTQueueIO, writeTQueue) import qualified Data.Text as T import Fmt ((+|), (|+)) -import Handlers (AdminOverview, - adminOverviewImpl, - statusImpl) +import Handlers (AdminOverview (AdminOverview), + MapService (MapService), + stateImpl, statusImpl) import HtmlOrphans () import Network.Wai.Handler.Warp (defaultSettings, runSettings, setPort) @@ -43,6 +43,9 @@ import Server (JobStatus, Org (..), import Worker (Job (Job), linterThread) +-- | that thing we need to replace the hub +type MapServiceAPI = "api" :> "maps" :> "list" :> Get '[JSON] MapService + -- | abstract api type API format = -- "submit" :> ReqBody '[JSON] RemoteRef :> Post '[format] UUID @@ -52,17 +55,19 @@ type API format = -- | actual set of routes: api for json & html + static pages from disk type Routes = "api" :> API JSON + :<|> MapServiceAPI :<|> API HTML -- websites mirror the API exactly :<|> Raw -- | API's implementation jsonAPI :: forall format. MVar ServerState -> Server (API format) jsonAPI state = statusImpl state - :<|> adminOverviewImpl state + :<|> stateImpl @AdminOverview state -- | Complete set of routes: API + HTML sites server :: MVar ServerState -> Server Routes server state = jsonAPI @JSON state + :<|> stateImpl @MapService state :<|> jsonAPI @HTML state :<|> serveDirectoryWebApp "./static" -- cgit v1.2.3