You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
929 B
36 lines
929 B
package webhookeverything
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"git.samuelpua.com/telboon/webhook-everything/backend/internal/common"
|
|
"github.com/go-chi/chi"
|
|
"github.com/go-chi/render"
|
|
)
|
|
|
|
// Handles pre-generated webhooks
|
|
// @Summary Pre-generated webhooks
|
|
// @Description Description
|
|
// @Tags Webhook
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param webhookID path string true "Pre-registered Webhook Path"
|
|
// @Success 200 {object} common.TextResponse
|
|
// @Failure 500 {object} common.ErrResponse
|
|
// @Router /webhook/routes/{webhookID} [POST]
|
|
func (env *Env) handleWebhook(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
routeID := chi.URLParam(r, "routeID")
|
|
log.Printf("Webhook received for routeID: %s", routeID)
|
|
_ = ctx
|
|
|
|
err := env.forwardHookToTelegram(r, routeID)
|
|
|
|
if err != nil {
|
|
render.Render(w, r, common.ErrInternalError(err))
|
|
return
|
|
}
|
|
|
|
render.Render(w, r, common.NewGenericTextResponse("success", ""))
|
|
}
|