<commit_before>package trello

import (
	"encoding/json"
	"fmt"
	"github.com/joonasmyhrberg/go-trello"
	"io/ioutil"
	"net/http"
)

type WebhookResponse struct {
	Action trello.Action `json:"action"`
}

func WebhookHandler(w http.ResponseWriter, r *http.Request) {
	switch r.Method {
	case "HEAD":
		handlePing(w)
	case "POST":
		response, err := handleUpdate(w, r)
		if err != nil {
			fmt.Println("Error handling update: ", err)
		}
		handleAction(response.Action)
	default:
		w.WriteHeader(http.StatusInternalServerError)
	}
}

func handlePing(w http.ResponseWriter) {
	fmt.Println("Received webhook creation ping, responding with 200")
	w.WriteHeader(http.StatusOK)
}

func handleUpdate(w http.ResponseWriter, r *http.Request) (webhookResponse WebhookResponse, err error) {

	body, err := ioutil.ReadAll(r.Body)
	err = json.Unmarshal(body, &webhookResponse)
	if err != nil {
		fmt.Println("Failed to decode action JSON with error: ", err.Error())
		return WebhookResponse{}, err
	}
	return
}
<commit_msg>Call action handler on update<commit_after>package trello

import (
	"encoding/json"
	"fmt"
	"github.com/joonasmyhrberg/go-trello"
	"io/ioutil"
	"net/http"
)

type WebhookResponse struct {
	Action trello.Action `json:"action"`
}

func WebhookHandler(w http.ResponseWriter, r *http.Request) {
	switch r.Method {
	case "HEAD":
		handlePing(w)
	case "POST":
		response, err := handleUpdate(w, r)
		if err != nil {
			fmt.Println("Error handling update: ", err)
		}
		trelloConfig.ActionHandler(response.Action)
	default:
		w.WriteHeader(http.StatusInternalServerError)
	}
}

func handlePing(w http.ResponseWriter) {
	fmt.Println("Received webhook creation ping, responding with 200")
	w.WriteHeader(http.StatusOK)
}

func handleUpdate(w http.ResponseWriter, r *http.Request) (webhookResponse WebhookResponse, err error) {

	body, err := ioutil.ReadAll(r.Body)
	err = json.Unmarshal(body, &webhookResponse)
	if err != nil {
		fmt.Println("Failed to decode action JSON with error: ", err.Error())
		return WebhookResponse{}, err
	}
	return
}

{'fraction_non_alphanumeric': 0.1276908023483366, 'fraction_numerical': 0.0029354207436399216, 'mean_word_length': 4.809659090909091, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2178228', 'n_tokens_mistral': 754, 'n_tokens_neox': 714, 'n_words': 166}