MCPcopy
hub / github.com/github/github-mcp-server / WithRequestMatch

Function WithRequestMatch

pkg/github/helper_test.go:702–720  ·  view source on GitHub ↗
(pattern EndpointPattern, response any)

Source from the content-addressed store, hash-verified

700}
701
702func WithRequestMatch(pattern EndpointPattern, response any) MockBackendOption {
703 return func(handlers map[string]http.HandlerFunc) {
704 method, path := parseEndpointPattern(pattern)
705 handlers[method+" "+path] = func(w http.ResponseWriter, _ *http.Request) {
706 w.WriteHeader(http.StatusOK)
707 switch v := response.(type) {
708 case string:
709 _, _ = w.Write([]byte(v))
710 case []byte:
711 _, _ = w.Write(v)
712 default:
713 data, err := json.Marshal(v)
714 if err == nil {
715 _, _ = w.Write(data)
716 }
717 }
718 }
719 }
720}
721
722func WithRequestMatchHandler(pattern EndpointPattern, handler http.HandlerFunc) MockBackendOption {
723 return func(handlers map[string]http.HandlerFunc) {

Callers 8

Test_PushFilesFunction · 0.85
Test_ListBranchesFunction · 0.85
Test_DeleteFileFunction · 0.85
Test_GetTagFunction · 0.85
Test_ListReleasesFunction · 0.85
Test_GetLatestReleaseFunction · 0.85
Test_GetReleaseByTagFunction · 0.85

Calls 3

parseEndpointPatternFunction · 0.85
WriteHeaderMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected