Commit 8094cd18 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Garg Version api.

parent dbb1ec70
...@@ -199,19 +199,25 @@ type GargAPI = "api" :> Summary "API " :> GargAPIVersion ...@@ -199,19 +199,25 @@ type GargAPI = "api" :> Summary "API " :> GargAPIVersion
-- | TODO :<|> Summary "Latest API" :> GargAPI' -- | TODO :<|> Summary "Latest API" :> GargAPI'
type GargAPIVersion = "v1.0" :> Summary "v1.0: " :> GargAPI' type GargAPIVersion = "v1.0"
:> Summary "Garg API Version "
:> GargAPI'
type GargVersion = "version"
:> Summary "Backend version"
:> Get '[JSON] Text
type GargAPI' = type GargAPI' =
-- Auth endpoint -- Auth endpoint
"auth" :> Summary "AUTH API" "auth" :> Summary "AUTH API"
:> ReqBody '[JSON] AuthRequest :> ReqBody '[JSON] AuthRequest
:> Post '[JSON] AuthResponse :> Post '[JSON] AuthResponse
:<|> "version" :> Summary "Backend version" :<|> GargVersion
:> Get '[JSON] Text -- TODO-ACCESS here we want to request a particular header for
-- TODO-ACCESS here we want to request a particular header for
-- auth and capabilities. -- auth and capabilities.
:<|> GargPrivateAPI :<|> GargPrivateAPI
type GargPrivateAPI = SA.Auth '[SA.JWT, SA.Cookie] AuthenticatedUser :> GargPrivateAPI' type GargPrivateAPI = SA.Auth '[SA.JWT, SA.Cookie] AuthenticatedUser :> GargPrivateAPI'
type GargAdminAPI type GargAdminAPI
...@@ -341,7 +347,11 @@ server :: forall env. EnvC env => env -> IO (Server API) ...@@ -341,7 +347,11 @@ server :: forall env. EnvC env => env -> IO (Server API)
server env = do server env = do
-- orchestrator <- scrapyOrchestrator env -- orchestrator <- scrapyOrchestrator env
pure $ schemaUiServer swaggerDoc pure $ schemaUiServer swaggerDoc
:<|> hoistServerWithContext (Proxy :: Proxy GargAPI) (Proxy :: Proxy AuthContext) transform serverGargAPI :<|> hoistServerWithContext
(Proxy :: Proxy GargAPI)
(Proxy :: Proxy AuthContext)
transform
serverGargAPI
:<|> frontEndServer :<|> frontEndServer
where where
transform :: forall a. GargServerM env GargError a -> Handler a transform :: forall a. GargServerM env GargError a -> Handler a
...@@ -353,13 +363,14 @@ serverGargAPI -- orchestrator ...@@ -353,13 +363,14 @@ serverGargAPI -- orchestrator
:<|> gargVersion :<|> gargVersion
:<|> serverPrivateGargAPI :<|> serverPrivateGargAPI
-- :<|> orchestrator -- :<|> orchestrator
where
gargVersion :: GargServer Text gargVersion :: GargServer GargVersion
gargVersion = pure $ (showVersion PG.version :: Text) gargVersion = pure (cs $ showVersion PG.version)
serverPrivateGargAPI :: GargServerT env err (GargServerM env err) GargPrivateAPI serverPrivateGargAPI :: GargServerT env err (GargServerM env err) GargPrivateAPI
serverPrivateGargAPI (Authenticated auser) = serverPrivateGargAPI' auser serverPrivateGargAPI (Authenticated auser) = serverPrivateGargAPI' auser
serverPrivateGargAPI _ = throwAll' (_ServerError # err401) serverPrivateGargAPI _ = throwAll' (_ServerError # err401)
-- Here throwAll' requires a concrete type for the monad. -- Here throwAll' requires a concrete type for the monad.
-- TODO-SECURITY admin only: withAdmin -- TODO-SECURITY admin only: withAdmin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment