mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
default to raspberrypi if arch does not exit
This commit is contained in:
@@ -23,12 +23,14 @@ import Handler.Util (queryParamAs, getArchQuery)
|
||||
import Lib.Types.Emver (Version, parseVersion)
|
||||
import Model (EntityField (..), OsVersion (..))
|
||||
import Orphans.Emver ()
|
||||
import Startlude (Bool (..), Down (..), Eq, Generic, Maybe (..), Ord ((<)), Show, Text, const, filter, fst, head, maybe, pure, sortOn, ($), (&&&), (.), (<$>), (<&>), (<=), (>>=))
|
||||
import Startlude (Bool (..), Down (..), Eq, Generic, Maybe (..), Ord ((<)), Show, Text, const, filter, fst, head, maybe, pure, sortOn, ($), (&&&), (.), (<$>), (<&>), (<=))
|
||||
import Yesod (ToContent (toContent), ToTypedContent (..), YesodPersist (runDB), getsYesod, sendResponseStatus)
|
||||
import Yesod.Core.Types (JSONResponse (..))
|
||||
import Settings (AppSettings(maxEosVersion))
|
||||
import Network.HTTP.Types (status400)
|
||||
import Lib.Error (S9Error(InvalidParamsE))
|
||||
import Lib.Types.Core (OsArch(RASPBERRYPI))
|
||||
import Data.Maybe (fromMaybe)
|
||||
|
||||
|
||||
data EosRes = EosRes
|
||||
@@ -49,9 +51,7 @@ instance ToTypedContent EosRes where
|
||||
getEosVersionR :: Handler (JSONResponse (Maybe EosRes))
|
||||
getEosVersionR = do
|
||||
currentEosVersion <- queryParamAs "eos-version" parseVersion
|
||||
getArchQuery >>= \case
|
||||
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "arch")
|
||||
Just arch -> do
|
||||
arch <- fromMaybe RASPBERRYPI <$> getArchQuery
|
||||
case currentEosVersion of
|
||||
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "eos-version")
|
||||
Just currentEosVersion' -> do
|
||||
|
||||
Reference in New Issue
Block a user