rename endpoints

This commit is contained in:
Lucy Cifferello
2021-08-23 11:27:35 -06:00
parent 008b81235d
commit f81d76eb6a
2 changed files with 31 additions and 3 deletions

View File

@@ -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