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 Lib.Types.Emver (Version, parseVersion)
|
||||||
import Model (EntityField (..), OsVersion (..))
|
import Model (EntityField (..), OsVersion (..))
|
||||||
import Orphans.Emver ()
|
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 (ToContent (toContent), ToTypedContent (..), YesodPersist (runDB), getsYesod, sendResponseStatus)
|
||||||
import Yesod.Core.Types (JSONResponse (..))
|
import Yesod.Core.Types (JSONResponse (..))
|
||||||
import Settings (AppSettings(maxEosVersion))
|
import Settings (AppSettings(maxEosVersion))
|
||||||
import Network.HTTP.Types (status400)
|
import Network.HTTP.Types (status400)
|
||||||
import Lib.Error (S9Error(InvalidParamsE))
|
import Lib.Error (S9Error(InvalidParamsE))
|
||||||
|
import Lib.Types.Core (OsArch(RASPBERRYPI))
|
||||||
|
import Data.Maybe (fromMaybe)
|
||||||
|
|
||||||
|
|
||||||
data EosRes = EosRes
|
data EosRes = EosRes
|
||||||
@@ -49,9 +51,7 @@ instance ToTypedContent EosRes where
|
|||||||
getEosVersionR :: Handler (JSONResponse (Maybe EosRes))
|
getEosVersionR :: Handler (JSONResponse (Maybe EosRes))
|
||||||
getEosVersionR = do
|
getEosVersionR = do
|
||||||
currentEosVersion <- queryParamAs "eos-version" parseVersion
|
currentEosVersion <- queryParamAs "eos-version" parseVersion
|
||||||
getArchQuery >>= \case
|
arch <- fromMaybe RASPBERRYPI <$> getArchQuery
|
||||||
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "arch")
|
|
||||||
Just arch -> do
|
|
||||||
case currentEosVersion of
|
case currentEosVersion of
|
||||||
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "eos-version")
|
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "eos-version")
|
||||||
Just currentEosVersion' -> do
|
Just currentEosVersion' -> do
|
||||||
|
|||||||
Reference in New Issue
Block a user