package main import ( "fmt" "net/http" "io" "context" "uebucch/manager" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "UeBucch!") }) http.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) { webHookName := r.URL.Query().Get("name") redisClient := manager.NewRedisClient() body, _ := io.ReadAll(r.Body) res := redisClient.LPush(context.Background(), webHookName, body) if res.Err() != nil { fmt.Fprintf(w, "Error: %s", res.Err()) return } fmt.Fprintf(w, "Webhook created!") }) http.HandleFunc("/webhooks", func(w http.ResponseWriter, r *http.Request) { webHooks, err := manager.GetWebhooks(context.Background(), manager.NewRedisClient()) if err != nil { fmt.Fprintf(w, "Error: %s", err) return } for _, webHook := range webHooks { fmt.Fprintf(w, "Webhook: %s", webHook) } }) http.ListenAndServe(":8080", nil) }