MCPcopy Create free account
hub / github.com/bytebase/bytebase / handler

Method handler

backend/api/mcp/tool_change_test.go:74–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72}
73
74func (m *changeMock) handler() http.Handler {
75 listHandler := mockListDatabases(m.databases)
76 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
77 w.Header().Set("Content-Type", "application/json")
78
79 switch {
80 case strings.Contains(r.URL.Path, "SheetService/CreateSheet"):
81 m.captureBody(r, &m.capturedSheet)
82 w.WriteHeader(m.sheetStatus)
83 _ = json.NewEncoder(w).Encode(m.sheetResponse)
84
85 case strings.Contains(r.URL.Path, "PlanService/RunPlanChecks"):
86 w.WriteHeader(m.runPlanChecksStatus)
87 _ = json.NewEncoder(w).Encode(map[string]any{})
88
89 case strings.Contains(r.URL.Path, "PlanService/GetPlanCheckRun"):
90 w.WriteHeader(m.planCheckRunStatus)
91 _ = json.NewEncoder(w).Encode(m.planCheckRunResponse)
92
93 case strings.Contains(r.URL.Path, "PlanService/CreatePlan"):
94 m.captureBody(r, &m.capturedPlan)
95 w.WriteHeader(m.planStatus)
96 _ = json.NewEncoder(w).Encode(m.planResponse)
97
98 case strings.Contains(r.URL.Path, "IssueService/CreateIssue"):
99 m.captureBody(r, &m.capturedIssue)
100 w.WriteHeader(m.issueStatus)
101 _ = json.NewEncoder(w).Encode(m.issueResponse)
102
103 case strings.Contains(r.URL.Path, "RolloutService/CreateRollout"):
104 m.captureBody(r, &m.capturedRollout)
105 w.WriteHeader(m.rolloutStatus)
106 _ = json.NewEncoder(w).Encode(m.rolloutResponse)
107
108 case strings.Contains(r.URL.Path, "DatabaseService/ListDatabases"):
109 listHandler.ServeHTTP(w, r)
110
111 default:
112 w.WriteHeader(http.StatusNotFound)
113 _ = json.NewEncoder(w).Encode(map[string]any{"message": "unknown path"})
114 }
115 })
116}
117
118func (m *changeMock) captureBody(r *http.Request, target *map[string]any) {
119 var body map[string]any

Callers 1

newChangeTestServerFunction · 0.45

Calls 3

captureBodyMethod · 0.95
mockListDatabasesFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected