MCPcopy Index your code
hub / github.com/github/github-mcp-server / alwaysNextPageHandler

Function alwaysNextPageHandler

pkg/github/ui_tools_test.go:79–93  ·  view source on GitHub ↗

alwaysNextPageHandler returns a REST handler that always advertises another page via the Link header, regardless of the page requested. It drives a pagination loop purely off the page cap so tests can assert ui_get stops at uiGetMaxPages and sets has_more=true. The same body is returned for every pa

(t *testing.T, body any)

Source from the content-addressed store, hash-verified

77// has_more=true. The same body is returned for every page, so the number of items
78// collected equals the number of pages fetched.
79func alwaysNextPageHandler(t *testing.T, body any) http.HandlerFunc {
80 t.Helper()
81 return func(w http.ResponseWriter, r *http.Request) {
82 page := 1
83 if p := r.URL.Query().Get("page"); p != "" {
84 if parsed, err := strconv.Atoi(p); err == nil {
85 page = parsed
86 }
87 }
88 w.Header().Set("Link", fmt.Sprintf(`<https://api.github.com/next?page=%d>; rel="next"`, page+1))
89 w.Header().Set("Content-Type", "application/json")
90 w.WriteHeader(http.StatusOK)
91 _ = json.NewEncoder(w).Encode(body)
92 }
93}
94
95func Test_UIGet(t *testing.T) {
96 // Verify tool definition

Callers 1

Test_UIGetFunction · 0.85

Calls 2

HeaderMethod · 0.80
WriteHeaderMethod · 0.80

Tested by

no test coverage detected