mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
36 lines
1.3 KiB
Haskell
36 lines
1.3 KiB
Haskell
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
{-# LANGUAGE RecordWildCards #-}
|
|
|
|
module Handler.Version where
|
|
|
|
import Startlude hiding ( Handler )
|
|
|
|
import Yesod.Core
|
|
|
|
import Data.String.Interpolate.IsString
|
|
( i )
|
|
import Foundation
|
|
import Handler.Types.Status
|
|
import Lib.Error ( S9Error(NotFoundE) )
|
|
import Lib.PkgRepository ( getBestVersion )
|
|
import Lib.Types.AppIndex ( PkgId )
|
|
import Network.HTTP.Types.Status ( status404 )
|
|
import Settings
|
|
import Util.Shared ( getVersionSpecFromQuery
|
|
, orThrow
|
|
)
|
|
|
|
getVersionR :: Handler AppVersionRes
|
|
getVersionR = AppVersionRes . registryVersion . appSettings <$> getYesod
|
|
|
|
getPkgVersionR :: PkgId -> Handler AppVersionRes
|
|
getPkgVersionR pkg = do
|
|
spec <- getVersionSpecFromQuery
|
|
AppVersionRes <$> getBestVersion pkg spec `orThrow` sendResponseStatus
|
|
status404
|
|
(NotFoundE [i|Version for #{pkg} satisfying #{spec}|])
|