MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / RegisterHook

Method RegisterHook

api/hooks.go:12–25  ·  view source on GitHub ↗

RegisterHook handles the registration of a new webhook.

(c *gin.Context)

Source from the content-addressed store, hash-verified

10
11// RegisterHook handles the registration of a new webhook.
12func (a *Api) RegisterHook(c *gin.Context) {
13 var hook hooks.Hook
14 if err := c.ShouldBindJSON(&hook); err != nil {
15 c.JSON(http.StatusBadRequest, apierror.NewAPIError(apierror.ErrInvalidInput, "invalid hook data", err))
16 return
17 }
18
19 if err := a.ledgerforge.Hooks.RegisterHook(c.Request.Context(), &hook); err != nil {
20 c.JSON(http.StatusBadRequest, apierror.NewAPIError(apierror.ErrInvalidInput, "failed to register hook", err))
21 return
22 }
23
24 c.JSON(http.StatusCreated, hook)
25}
26
27// UpdateHook handles updating an existing webhook.
28func (a *Api) UpdateHook(c *gin.Context) {

Callers

nothing calls this directly

Calls 2

NewAPIErrorFunction · 0.92
RegisterHookMethod · 0.65

Tested by

no test coverage detected