mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
switch from conduit responses to file responses
This commit is contained in:
@@ -18,9 +18,11 @@ import Network.HTTP.Types ( status404 )
|
||||
import System.FilePath ( (<.>)
|
||||
, takeBaseName
|
||||
)
|
||||
import Yesod.Core ( TypedContent
|
||||
import Yesod.Core ( Content(ContentFile)
|
||||
, TypedContent
|
||||
, addHeader
|
||||
, notFound
|
||||
, respond
|
||||
, respondSource
|
||||
, sendChunkBS
|
||||
, sendResponseStatus
|
||||
@@ -78,11 +80,10 @@ getAppR file = do
|
||||
`orThrow` sendResponseStatus status404 (NotFoundE [i|#{pkg} satisfying #{versionSpec}|])
|
||||
addPackageHeader pkg version
|
||||
void $ recordMetrics pkg version
|
||||
(len, src) <- getPackage pkg version >>= \case
|
||||
pkgPath <- getPackage pkg version >>= \case
|
||||
Nothing -> sendResponseStatus status404 (NotFoundE [i|#{pkg}@#{version}|])
|
||||
Just a -> pure a
|
||||
addHeader "Content-Length" (show len)
|
||||
respondSource typeOctet $ src .| awaitForever sendChunkBS
|
||||
respond typeOctet $ ContentFile pkgPath Nothing
|
||||
|
||||
|
||||
recordMetrics :: PkgId -> Version -> Handler ()
|
||||
|
||||
Reference in New Issue
Block a user