From 99dba0e273ff466bed444c0f44afc90b8845fa50 Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Mon, 23 Aug 2021 11:27:35 -0600 Subject: [PATCH] rename endpoints --- config/routes | 7 ++++--- src/Handler/Icons.hs | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/config/routes b/config/routes index cd2cb40..3a6e4d8 100644 --- a/config/routes +++ b/config/routes @@ -1,10 +1,11 @@ !/package/#S9PK AppR GET -- get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec} -/data CategoriesR GET -- get all marketplace categories -/packages PackageListR GET -- filter marketplace services by various query params +/marketplace/package/data CategoriesR GET -- get all marketplace categories +/marketplace/package/index PackageListR GET -- filter marketplace services by various query params /eos EosR GET -- get eos information -/version/latest VersionLatestR GET -- get latest version of apps in query param id +/marketplace/latest-version VersionLatestR GET -- get latest version of apps in query param id /package/manifest/#AppIdentifier AppManifestR GET -- get app manifest from appmgr -- ?version={semver-spec} +/marketplace/package/release-notes getReleaseNotesR GET -- get release notes for package - expects query param of id= -- TODO deprecate !/sys/#SYS_EXTENSIONLESS SysR GET -- get most recent sys app -- ?spec={semver-spec} diff --git a/src/Handler/Icons.hs b/src/Handler/Icons.hs index 3c54854..d05eb96 100644 --- a/src/Handler/Icons.hs +++ b/src/Handler/Icons.hs @@ -19,6 +19,19 @@ import System.FilePath (()) getIconsR :: Extension "png" -> Handler TypedContent getIconsR ext = do -- @TODO switch to getting from service directory + AppSettings{..} <- appSettings <$> getYesod + mPng <- liftIO $ getVersionedFileFromDir (resourcesDir "icons") ext + case mPng of + Nothing -> notFound + Just pngPath -> do + putStrLn @Text $ show pngPath + exists <- liftIO $ doesFileExist pngPath + if exists + then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS + else notFound + +getLicenseR :: Extension "" -> Handler TypedContent +getLicenseR ext = do AppSettings{..} <- appSettings <$> getYesod mPng <- liftIO $ getUnversionedFileFromDir (resourcesDir "icons") ext case mPng of @@ -29,3 +42,17 @@ getIconsR ext = do if exists then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS else notFound + +getMarkdownR :: Extension "md" -> Handler TypedContent +getMarkdownR ext = do + -- @TODO switch to getting from service directory + AppSettings{..} <- appSettings <$> getYesod + mPng <- liftIO $ getUnversionedFileFromDir (resourcesDir "icons") ext + case mPng of + Nothing -> notFound + Just pngPath -> do + putStrLn @Text $ show pngPath + exists <- liftIO $ doesFileExist pngPath + if exists + then respondSource typePlain $ CB.sourceFile pngPath .| awaitForever sendChunkBS + else notFound \ No newline at end of file