Init commit, base struct and redis connection

This commit is contained in:
Schrody
2026-01-29 17:55:14 +01:00
parent 58164d4b10
commit 9ae5696aec
10 changed files with 206 additions and 0 deletions

28
handlers/worker.go Normal file
View File

@@ -0,0 +1,28 @@
package handlers
import (
"bytes"
"log"
"net/http"
"time"
"uebucch/structs"
)
func worker(id int, jobs <-chan structs.WebhookJob) {
client := &http.Client{Timeout: 10 * time.Second}
for job := range jobs {
req, _ := http.NewRequest(job.Method, job.TargetURL, bytes.NewBuffer(job.Payload))
for k, v := range job.Headers {
req.Header[k] = v
}
resp, err := client.Do(req)
if err != nil {
log.Printf("Worker %d: Errore nell'inoltro: %v", id, err)
continue
}
resp.Body.Close()
log.Printf("Worker %d: Inoltrato con successo a %s", id, job.TargetURL)
}
}