Skip to content

Add API endpoint to request contents of multiple files simultaniously #34139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

denyskon
Copy link
Member

@denyskon denyskon commented Apr 7, 2025

Adds an API POST endpoint under /repos/{owner}/{repo}/files which receives a list of paths and returns a paginated list of the contents of these files.

This API endpoint will be helpful for applications like headless CMS (reference: sveltia/sveltia-cms#198) which need to retrieve a large number of files by reducing the amount of needed API calls.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 7, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Apr 7, 2025
@denyskon denyskon added this to the 1.24.0 milestone Apr 7, 2025
@denyskon denyskon added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Apr 7, 2025
@denyskon denyskon requested a review from wxiaoguang April 7, 2025 14:27
@wxiaoguang
Copy link
Contributor

Some thoughts in my mind:

  1. Why it is a "POST" endpoint? If I understand correctly, it "GETs"
  2. Does GitHub have a simliar API? If yes, we'd better to follow, if no, let's invent
  3. It needs some tests (almost all existing APIs are covered by tests, otherwise it would easily break in the future if something changes)

@denyskon
Copy link
Member Author

denyskon commented Apr 7, 2025

  1. IIRC, the HTTP spec says or has said that GET requests should not contain a body - that's why it isn't an option. Post is the next best choice I think.

  2. GitHub doesn't have a similar API, as such functionality is now being served through their GraphQL API. This, however, is clearly out of scope for near future, so I think that such an API endpoint would be helpful :)

  3. I can add some tests...

@silverwind
Copy link
Member

  1. IIRC, the HTTP spec says or has said that GET requests should not contain a body - that's why it isn't an option. Post is the next best choice I think.

HTTP QUERY is a proposed standard to solve the GET-with-body problem. Tooling support is probably not there yet, but if it works in your case, it might be an option to use it already.

Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. IIRC, the HTTP spec says or has said that GET requests should not contain a body - that's why it isn't an option. Post is the next best choice I think.

I see, I missed the Files []string field, it would be quite large so it is POST's job.

@denyskon denyskon requested a review from wxiaoguang April 10, 2025 07:14
@denyskon
Copy link
Member Author

@wxiaoguang Added an integration test

@denyskon denyskon requested a review from a team April 11, 2025 14:13
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants