MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / WebhookReceiver

Function WebhookReceiver

internal/testutil/server.go:341–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

339}
340
341func WebhookReceiver(t *testing.T) *WebhookReceiverResult {
342 t.Helper()
343
344 result := &WebhookReceiverResult{}
345
346 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
347 rawBody, err := io.ReadAll(r.Body)
348 if err != nil {
349 http.Error(w, "read error", 500)
350 return
351 }
352 var payload webhook.Payload
353 if err := json.Unmarshal(rawBody, &payload); err != nil {
354 http.Error(w, fmt.Sprintf("unmarshal error: %v", err), 400)
355 return
356 }
357
358 result.mu.Lock()
359 result.payloads = append(result.payloads, ReceivedPayload{
360 Body: payload,
361 Headers: r.Header.Clone(),
362 RawBody: rawBody,
363 })
364 result.mu.Unlock()
365
366 w.WriteHeader(200)
367 }))
368
369 result.Server = server
370 t.Cleanup(server.Close)
371
372 return result
373}

Callers 3

TestOutboundAgentToAgentFunction · 0.92

Calls 4

CloneMethod · 0.80
CleanupMethod · 0.80
ErrorMethod · 0.45
WriteHeaderMethod · 0.45

Tested by 3

TestOutboundAgentToAgentFunction · 0.74