From 2df99d40e96bf3960a0876cde4aa32eb85c61448 Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:00:09 -0700 Subject: [PATCH] handle redirecting to marketplace paths for brochure --- config/routes | 1 + src/Handler/Root.hs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/routes b/config/routes index a1ade99..fa71767 100644 --- a/config/routes +++ b/config/routes @@ -1,4 +1,5 @@ / RootR GET +/marketplace/#PkgId MarketplaceR GET -- EOS API V0 /eos/v0/latest EosVersionR GET -- get eos information diff --git a/src/Handler/Root.hs b/src/Handler/Root.hs index a21a600..c831521 100644 --- a/src/Handler/Root.hs +++ b/src/Handler/Root.hs @@ -4,8 +4,17 @@ import Yesod import Foundation import qualified Data.Text as T import Settings (AppSettings(registryHostname, marketplaceName)) +import Network.Wai (Request(pathInfo)) getRootR :: HandlerFor RegistryCtx () getRootR = do (url, name) <- getsYesod $ (registryHostname &&& marketplaceName) . appSettings - redirect $ T.pack "https://marketplace.start9.com?api=" <> url <> T.pack "&name=" <> name \ No newline at end of file + redirect $ T.pack "https://marketplace.start9.com?api=" <> url <> T.pack "&name=" <> name + +getMarketplaceR :: 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 \ No newline at end of file