MCPcopy
hub / github.com/Tencent/WeKnora / runAPI

Function runAPI

cli/cmd/api/api.go:194–199  ·  view source on GitHub ↗

runAPI is the testable core: validate inputs, dispatch via Service.Raw, classify status, and emit either the raw body or a JSON object. The caller is responsible for resolving the method (defaults / auto-POST) and uppercasing it; runAPI guards against unsupported values like `-X PATCH-INVALID` reach

(ctx context.Context, opts *Options, fopts *cmdutil.FormatOptions, svc Service, method, path string, paginate bool)

Source from the content-addressed store, hash-verified

192// fetched and merged into a single {data, total} JSON response. For
193// non-GET methods paginate is silently ignored (no offset semantic).
194func runAPI(ctx context.Context, opts *Options, fopts *cmdutil.FormatOptions, svc Service, method, path string, paginate bool) error {
195 if paginate && method == http.MethodGet {
196 return runAPIPaginated(ctx, opts, fopts, svc, path)
197 }
198 return runAPISingle(ctx, opts, fopts, svc, method, path)
199}
200
201// runAPISingle is the original single-call implementation of runAPI.
202func runAPISingle(ctx context.Context, opts *Options, fopts *cmdutil.FormatOptions, svc Service, method, path string) error {

Callers 14

NewCmdFunction · 0.85
TestAPI_GetSuccessFunction · 0.85
TestAPI_GetSuccess_JSONFunction · 0.85
TestAPI_InputFileFunction · 0.85
TestAPI_InputDash_StdinFunction · 0.85
TestAPI_NotFoundFunction · 0.85
TestAPI_PathWithoutSlashFunction · 0.85

Calls 2

runAPIPaginatedFunction · 0.85
runAPISingleFunction · 0.85

Tested by 13

TestAPI_GetSuccessFunction · 0.68
TestAPI_GetSuccess_JSONFunction · 0.68
TestAPI_InputFileFunction · 0.68
TestAPI_InputDash_StdinFunction · 0.68
TestAPI_NotFoundFunction · 0.68
TestAPI_PathWithoutSlashFunction · 0.68