RegisterHook handles the registration of a new webhook.
(c *gin.Context)
| 10 | |
| 11 | // RegisterHook handles the registration of a new webhook. |
| 12 | func (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. |
| 28 | func (a *Api) UpdateHook(c *gin.Context) { |
nothing calls this directly
no test coverage detected