initPackageContentsFeature :: ServerEnv -> CoreFeature -> CheckFeature -> IO PackageContentsFeature
initPackageContentsFeature env _ _ = do
    let store = serverBlobStore env
        resources = PackageContentsResource {
              packageContents                   = (resourceAt "/package/:package/src/..") { resourceGet = [("", serveContents store)] }
            , packageContentsCandidate          = (resourceAt "/package/:package/candidate/src/..") { resourceGet = [("", serveCandidateContents store)] }
            , packageContentsChangeLog          = (resourceAt "/package/:package/changelog") { resourceGet = [("changelog", serveChangeLog store)] }
            , packageContentsCandidateChangeLog = (resourceAt "/package/:package/candidate/changelog") { resourceGet = [("changelog", serveCandidateChangeLog store)] }

            , packageContentsChangeLogUri          = \pkgid -> renderResource (packageContentsChangeLog          resources) [display pkgid, display (packageName pkgid)]
            , packageContentsCandidateChangeLogUri = \pkgid -> renderResource (packageContentsCandidateChangeLog resources) [display pkgid, display (packageName pkgid)]
          }
    return PackageContentsFeature {
        featureInterface = (emptyHackageFeature "package-contents") {
          featureResources = map ($ resources) [packageContents, packageContentsCandidate, packageContentsChangeLog, packageContentsCandidateChangeLog]
        }
      , packageContentsResource = resources
      }


--TODO: use something other than runServerPartE for nice html error pages
initPackageContentsFeature :: ServerEnv -> CoreFeature -> CheckFeature -> IO PackageContentsFeature
initPackageContentsFeature env _ _ = do
    let store = serverBlobStore env
        resources = PackageContentsResource {
              packageContents                   = (resourceAt "/package/:package/src/..") { resourceGet = [("", serveContents store)] }
            , packageContentsCandidate          = (resourceAt "/package/:package/candidate/src/..") { resourceGet = [("", serveCandidateContents store)] }
            , packageContentsChangeLog          = (resourceAt "/package/:package/changelog") { resourceGet = [("changelog", serveChangeLog store)] }
            , packageContentsCandidateChangeLog = (resourceAt "/package/:package/candidate/changelog") { resourceGet = [("changelog", serveCandidateChangeLog store)] }

            , packageContentsChangeLogUri          = \pkgid -> renderResource (packageContentsChangeLog          resources) [display pkgid, display (packageName pkgid)]
            , packageContentsCandidateChangeLogUri = \pkgid -> renderResource (packageContentsCandidateChangeLog resources) [display pkgid, display (packageName pkgid)]
          }
    return PackageContentsFeature {
        featureInterface = (emptyHackageFeature "package-contents") {
          featureResources = map ($ resources) [packageContents, packageContentsCandidate, packageContentsChangeLog, packageContentsCandidateChangeLog]
        }
      , packageContentsResource = resources
      }


--TODO: use something other than runServerPartE for nice html error pages
initPackageContentsFeature env _ _ = do
    let store = serverBlobStore env
        resources = PackageContentsResource {
              packageContents                   = (resourceAt "/package/:package/src/..") { resourceGet = [("", serveContents store)] }
            , packageContentsCandidate          = (resourceAt "/package/:package/candidate/src/..") { resourceGet = [("", serveCandidateContents store)] }
            , packageContentsChangeLog          = (resourceAt "/package/:package/changelog") { resourceGet = [("changelog", serveChangeLog store)] }
            , packageContentsCandidateChangeLog = (resourceAt "/package/:package/candidate/changelog") { resourceGet = [("changelog", serveCandidateChangeLog store)] }

            , packageContentsChangeLogUri          = \pkgid -> renderResource (packageContentsChangeLog          resources) [display pkgid, display (packageName pkgid)]
            , packageContentsCandidateChangeLogUri = \pkgid -> renderResource (packageContentsCandidateChangeLog resources) [display pkgid, display (packageName pkgid)]
          }
    return PackageContentsFeature {
        featureInterface = (emptyHackageFeature "package-contents") {
          featureResources = map ($ resources) [packageContents, packageContentsCandidate, packageContentsChangeLog, packageContentsCandidateChangeLog]
        }
      , packageContentsResource = resources
      }


--TODO: use something other than runServerPartE for nice html error pages