Skip to content

Commit

Permalink
wip gitlab: GetUserRepositories simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan José Vázquez committed Dec 18, 2017
1 parent 18ba9e7 commit cb5273d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions core/src/main/scala/Gitlab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ object Gitlab {
case GetRelease(slug: Slug, releaseId: ID, t: AccessToken) => ???
case GetUserRepositories(t: AccessToken) =>
def go(uri: String)(accum: List[Repo]): List[Repo] = {
val EntityWithMeta(repos, pagination) = fetchWithMeta[List[Repo]](uri) { uri =>
http4s.Request(
headers = Headers(Header("PRIVATE-TOKEN", t.value)),
uri = uri)
}.run
val EntityWithMeta(repos, pagination) = authFetchWithMeta[List[Repo]](uri, t).run
val total = accum ++ repos
pagination.nextPage.fold(total) { page =>
val nextLink = pagination.links.getOrElse("next", cfg.repoEndpoint(page))
Expand All @@ -67,7 +63,6 @@ object Gitlab {
private[this] def authFetch[A: EntityDecoder](uri: String, token: AccessToken): Task[A] =
authFetchWithMeta(uri, token).map(_.entity)


private[this] def authFetchWithMeta[A: EntityDecoder](uri: String, token: AccessToken): Task[EntityWithMeta[A]] =
fetchWithMeta[A](uri) { uri =>
http4s.Request(
Expand Down

0 comments on commit cb5273d

Please sign in to comment.