Serve /index.html contents on route /

parent 04186169
......@@ -77,6 +77,7 @@ library:
- attoparsec
- base >=4.7 && <5
- base16-bytestring
- blaze-html
- bytestring
- case-insensitive
- cassava
......@@ -136,6 +137,7 @@ library:
- semigroups
- servant
- servant-auth
- servant-blaze
- servant-client
- servant-job
- servant-mock
......
......@@ -56,11 +56,15 @@ import Network.Wai
import Network.Wai.Handler.Warp hiding (defaultSettings)
import Servant
import Servant.HTML.Blaze (HTML)
import Servant.Mock (mock)
--import Servant.Job.Server (WithCallbacks)
import Servant.Static.TH.Internal.Server (fileTreeToServer)
import Servant.Static.TH.Internal.FileTree (fileTypeToFileTree, FileType(FileTypeFile))
import Servant.Swagger
import Servant.Swagger.UI
-- import Servant.API.Stream
import Text.Blaze.Html (Html)
--import Gargantext.API.Swagger
import Gargantext.Prelude
......@@ -258,17 +262,24 @@ type GargAPI' =
-- :<|> "ngrams" :> Capture "id" Int :> NodeAPI
-- :<|> "auth" :> Capture "id" Int :> NodeAPI
---------------------------------------------------------------------
type SwaggerFrontAPI = SwaggerAPI :<|> FrontEndAPI
type SwaggerFrontAPI = SwaggerAPI :<|> FrontEndAPI
type API = SwaggerFrontAPI :<|> GargAPI :<|> Get '[HTML] Html
type API = SwaggerFrontAPI :<|> GargAPI
---------------------------------------------------------------------
-- | Server declaration
-- | Server declarations
server :: Env -> IO (Server API)
server env = do
gargAPI <- serverGargAPI env
pure $ swaggerFront
:<|> gargAPI
:<|> serverIndex
serverGargAPI :: Env -> IO (Server GargAPI)
serverGargAPI env = do
-- orchestrator <- scrapyOrchestrator env
pure $ swaggerFront
:<|> auth conn
pure $ auth conn
:<|> roots conn
:<|> nodeAPI conn (Proxy :: Proxy HyperdataAny)
:<|> nodeAPI conn (Proxy :: Proxy HyperdataCorpus)
......@@ -282,6 +293,10 @@ server env = do
where
conn = env ^. env_conn
serverIndex :: Server (Get '[HTML] Html)
serverIndex = $(do (Just s) <- liftIO (fileTypeToFileTree (FileTypeFile "purescript-gargantext/dist/index.html"))
fileTreeToServer s)
---------------------------------------------------------------------
swaggerFront :: Server SwaggerFrontAPI
swaggerFront = schemaUiServer swaggerDoc
......@@ -295,7 +310,7 @@ makeApp :: Env -> IO Application
makeApp = fmap (serve api) . server
appMock :: Application
appMock = serve api (swaggerFront :<|> gargMock)
appMock = serve api (swaggerFront :<|> gargMock :<|> serverIndex)
---------------------------------------------------------------------
api :: Proxy API
......
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