netlify / git-gateway

A Gateway to Git APIs
MIT License
404 stars 89 forks source link

Feat: re-write GitHub pagination links #48

Open erezrokah opened 4 years ago

erezrokah commented 4 years ago

Not sure if a feature or a bug.

See here https://github.com/netlify/netlify-cms/pull/3135.

When working with GitHub paginated endpoints the next content URLs are sent back in the Link header. For example curl --head https://api.github.com/repos/erezrokah/netlify-cms-reproductions/pulls will return:

HTTP/1.1 200 OK
Date: Fri, 24 Jan 2020 07:18:44 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 580116
Server: GitHub.com
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 49
X-RateLimit-Reset: 1579852666
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "594fc31b8d42b4e4782492e5c7619d62"
X-GitHub-Media-Type: github.v3; format=json
Link: <https://api.github.com/repositories/233790256/pulls?page=2>; rel="next", <https://api.github.com/repositories/233790256/pulls?page=2>; rel="last"
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
Vary: Accept-Encoding
X-GitHub-Request-Id: FB16:3B0C0:5955597:6B4F95F:5E2A9A53

I think it makes sense for git-gateway to re-write them to make it easier for clients to follow.

erezrokah commented 4 years ago

Linking https://github.com/netlify/git-gateway/pull/17/files#diff-e4b5b46bf2cd2a2663c651d3358baf96R125 for context