Portability : POSIX
-}
+{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
---------------------------------------------------------------------
import qualified Gargantext.API.Public as Public
-import Gargantext.API.Admin.Auth (AuthContext, auth)
+import Gargantext.API.Admin.Auth.Types (AuthContext)
+import Gargantext.API.Admin.Auth (auth)
import Gargantext.API.Admin.FrontEnd (frontEndServer)
import Gargantext.API.Prelude
import Gargantext.API.Routes
import Gargantext.API.Swagger (swaggerDoc)
import Gargantext.API.ThrowAll (serverPrivateGargAPI)
+import Gargantext.Database.Query.Table.Node.Error (NodeError(..))
+import Gargantext.Database.Prelude (hasConfig)
import Gargantext.Prelude
import Gargantext.Prelude.Config (gc_url_backend_api)
-import Gargantext.Database.Prelude (config)
-serverGargAPI :: Text -> GargServerM env err GargAPI
+serverGargAPI :: MimeRender JSON err => Text -> GargServerM env err GargAPI
serverGargAPI baseUrl -- orchestrator
= auth
:<|> gargVersion
(Proxy :: Proxy GargAPI)
(Proxy :: Proxy AuthContext)
transform
- (serverGargAPI (env ^. config . gc_url_backend_api))
+ (serverGargAPI (env ^. hasConfig . gc_url_backend_api))
:<|> frontEndServer
where
transform :: forall a. GargM env GargError a -> Handler a
showAsServantErr :: GargError -> ServerError
+showAsServantErr (GargNodeError err@NoListFound) = err404 { errBody = BL8.pack $ show err }
+showAsServantErr (GargNodeError err@NoRootFound) = err404 { errBody = BL8.pack $ show err }
+showAsServantErr (GargNodeError err@NoCorpusFound) = err404 { errBody = BL8.pack $ show err }
+showAsServantErr (GargNodeError err@NoUserFound) = err404 { errBody = BL8.pack $ show err }
+showAsServantErr (GargNodeError err@(DoesNotExist _)) = err404 { errBody = BL8.pack $ show err }
showAsServantErr (GargServerError err) = err
-showAsServantErr a = err500 { errBody = BL8.pack $ show a }
\ No newline at end of file
+showAsServantErr a = err500 { errBody = BL8.pack $ show a }