API Generalize Header for get XY list endpoints #5256

Closed
opened 2025-11-02 06:19:18 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @6543 on GitHub (Apr 17, 2020).

Originally assigned to: @6543 on GitHub.

as title, if an api endpoint returns a list of objects it should:
A: support paggination (optional)
B: add max-obj-count to header

  • add this to API programming guidelinge

  • create header for all get list endpints

  • ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))

Originally created by @6543 on GitHub (Apr 17, 2020). Originally assigned to: @6543 on GitHub. as title, if an api endpoint returns a list of objects it should: A: support paggination (optional) B: add max-obj-count to header * [ ] add this to API programming guidelinge * [ ] create header for all get list endpints * `ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults))`
GiteaMirror added the type/proposalmodifies/api labels 2025-11-02 06:19:18 -06:00
Author
Owner

@zeripath commented on GitHub (May 16, 2020):

I would be cautious about assuming that we should always provide a full count - that can be very expensive in certain circumstances - (mostly circumstances that we've already committed to providing a count.)

@zeripath commented on GitHub (May 16, 2020): I would be cautious about assuming that we should always provide a full count - that can be very expensive in certain circumstances - (mostly circumstances that we've already committed to providing a count.)
Author
Owner

@6543 commented on GitHub (May 16, 2020):

good point ...

@6543 commented on GitHub (May 16, 2020): good point ...
Author
Owner

@6543 commented on GitHub (Jul 2, 2021):

... maybe it's better to add a help function named as ctx.SetResultHeader(...) to do it.

Originally posted by @a1012112796 in https://github.com/go-gitea/gitea/pull/16300#discussion_r662846010

@6543 commented on GitHub (Jul 2, 2021): ... maybe it's better to add a help function named as ``ctx.SetResultHeader(...)`` to do it. _Originally posted by @a1012112796 in https://github.com/go-gitea/gitea/pull/16300#discussion_r662846010_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5256