mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
alter endpoints to support dynamic versions
This commit is contained in:
22
src/Util/Shared.hs
Normal file
22
src/Util/Shared.hs
Normal file
@@ -0,0 +1,22 @@
|
||||
module Util.Shared where
|
||||
|
||||
import Startlude
|
||||
|
||||
import Data.Char
|
||||
import qualified Data.Text as T
|
||||
import Network.HTTP.Types
|
||||
import Yesod.Core
|
||||
|
||||
import Foundation
|
||||
import Lib.Registry
|
||||
import Lib.Semver
|
||||
import Lib.Types.Semver
|
||||
|
||||
getVersionFromQuery :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe AppVersion)
|
||||
getVersionFromQuery rootDir ext = do
|
||||
specString <- T.filter (not . isSpace) . fromMaybe "*" <$> lookupGetParam "spec"
|
||||
spec <- case readMaybe specString of
|
||||
Nothing -> sendResponseStatus status400 ("Invalid App Version Specification" :: Text)
|
||||
Just t -> pure t
|
||||
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
|
||||
pure $ version <$> getSpecifiedAppVersion spec appVersions
|
||||
Reference in New Issue
Block a user