merge add package header

This commit is contained in:
Lucy Cifferello
2021-07-01 18:39:15 -04:00
committed by Keagan McClelland
parent 40e7d5f097
commit 8f20f68c5e
5 changed files with 23 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ module Util.Shared where
import Startlude hiding (Handler)
import qualified Data.Text as T
import Data.Text.Encoding
import Network.HTTP.Types
import Yesod.Core
@@ -10,6 +11,8 @@ import Foundation
import Lib.Registry
import Lib.Types.Emver
import Data.Semigroup
import Lib.External.AppMgr
import Lib.Error
getVersionFromQuery :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe Version)
getVersionFromQuery rootDir ext = do
@@ -24,4 +27,9 @@ getBestVersion rootDir ext spec = do
appVersions <- liftIO $ getAvailableAppVersions rootDir ext
let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions
let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory
pure best
pure best
addPackageHeader :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m ()
addPackageHeader appMgrDir appDir appExt = do
packageHash <- handleS9ErrT $ getPackageHash appMgrDir appDir appExt
addHeader "X-S9PK-HASH" $ decodeUtf8 packageHash