MCPcopy Create free account
hub / github.com/bufbuild/buf-examples / Event

Method Event

bsr/webhooks/cmd/main.go:15–30  ·  view source on GitHub ↗
(
	_ context.Context,
	req *webhookv1alpha1.EventRequest,
)

Source from the content-addressed store, hash-verified

13type webhookEventHandler struct{}
14
15func (h *webhookEventHandler) Event(
16 _ context.Context,
17 req *webhookv1alpha1.EventRequest,
18) (*webhookv1alpha1.EventResponse, error) {
19 // Handle the type-safe incoming request for the push event:
20 switch req.GetEvent() {
21 case registryv1alpha1.WebhookEvent_WEBHOOK_EVENT_REPOSITORY_PUSH:
22 pushEvent := req.GetPayload().GetRepositoryPush()
23 fmt.Println("received repo push event:", pushEvent)
24 default:
25 fmt.Println("unknown event:", req.GetEvent())
26 }
27
28 // Webhook listener has an empty response
29 return &webhookv1alpha1.EventResponse{}, nil
30}
31
32// Connect handler based on: https://connectrpc.com/docs/go/getting-started#implement-handler
33func main() {

Callers 1

Calls

no outgoing calls

Tested by 1