Feature/marketplace path (#138)

* handle redirecting to marketplace paths for brochure

* fix new route setup
This commit is contained in:
Lucy
2023-11-08 11:03:13 -07:00
committed by GitHub
parent e3ec9b9cff
commit 0d5db1fa7a
3 changed files with 13 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
/ RootR GET
/marketplace/#PkgId MarketplaceR GET
-- EOS API V0
/eos/v0/latest EosVersionR GET -- get eos information

View File

@@ -186,7 +186,7 @@ import Handler.Admin (
postPkgUploadR,
)
import Handler.Eos (getEosR, getEosVersionR)
import Handler.Root(getRootR)
import Handler.Root(getRootR, getMarketplaceR)
import Handler.Package
import Lib.Ssl (
doesSslNeedRenew,

View File

@@ -4,8 +4,18 @@ import Yesod
import Foundation
import qualified Data.Text as T
import Settings (AppSettings(registryHostname, marketplaceName))
import Network.Wai (Request(pathInfo))
import Lib.Types.Core (PkgId)
getRootR :: HandlerFor RegistryCtx ()
getRootR = do
(url, name) <- getsYesod $ (registryHostname &&& marketplaceName) . appSettings
redirect $ T.pack "https://marketplace.start9.com?api=" <> url <> T.pack "&name=" <> name
redirect $ T.pack "https://marketplace.start9.com?api=" <> url <> T.pack "&name=" <> name
getMarketplaceR :: PkgId -> HandlerFor RegistryCtx ()
getMarketplaceR _ = do
(url, name) <- getsYesod $ (registryHostname &&& marketplaceName) . appSettings
req <- waiRequest
pathSegments <- pure $ pathInfo req
let pathPiece = "/" <> T.intercalate "/" pathSegments
redirect $ T.pack "https://marketplace.start9.com" <> pathPiece <> "?api=" <> url <> T.pack "&name=" <> name