serveContents' :: (DynamicPath -> ((PkgInfo -> ServerPartE Response) -> ServerPartE Response))
               -> BlobStorage -> DynamicPath -> ServerPart Response
serveContents' with_pkg_path store dpath = runServerPartE $ withContents $ \pkgid tarball index -> do
    -- if given a directory, the default page is index.html
    -- the default directory prefix is the package name itself (including the version)
    TarIndex.serveTarball ["index.html"] (display pkgid) tarball index
  where
    withContents :: (PackageId -> FilePath -> TarIndex -> ServerPartE Response) -> ServerPartE Response
    withContents func = with_pkg_path dpath $ \pkg ->
        case lookupTarball store pkg of
            Nothing -> fail "Could not serve package contents: no tarball exists."
            Just io -> liftIO io >>= \(fp, index) -> func (packageId pkg) fp index
serveContents' :: (DynamicPath -> ((PkgInfo -> ServerPartE Response) -> ServerPartE Response))
               -> BlobStorage -> DynamicPath -> ServerPart Response
serveContents' with_pkg_path store dpath = runServerPartE $ withContents $ \pkgid tarball index -> do
    -- if given a directory, the default page is index.html
    -- the default directory prefix is the package name itself (including the version)
    TarIndex.serveTarball ["index.html"] (display pkgid) tarball index
  where
    withContents :: (PackageId -> FilePath -> TarIndex -> ServerPartE Response) -> ServerPartE Response
    withContents func = with_pkg_path dpath $ \pkg ->
        case lookupTarball store pkg of
            Nothing -> fail "Could not serve package contents: no tarball exists."
            Just io -> liftIO io >>= \(fp, index) -> func (packageId pkg) fp index
serveContents' with_pkg_path store dpath = runServerPartE $ withContents $ \pkgid tarball index -> do
    -- if given a directory, the default page is index.html
    -- the default directory prefix is the package name itself (including the version)
    TarIndex.serveTarball ["index.html"] (display pkgid) tarball index
  where
    withContents :: (PackageId -> FilePath -> TarIndex -> ServerPartE Response) -> ServerPartE Response
    withContents func = with_pkg_path dpath $ \pkg ->
        case lookupTarball store pkg of
            Nothing -> fail "Could not serve package contents: no tarball exists."
            Just io -> liftIO io >>= \(fp, index) -> func (packageId pkg) fp index