<commit_before>package webhook

import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net"
	"net/http"
)

type Registry struct {
	UpdatableList
}

// jsonResponse is an internal convenience function to write a json response
func jsonResponse(rw http.ResponseWriter, code int, msg string) {
	rw.Header().Set("Content-Type", "application/json")
	rw.WriteHeader(code)
	rw.Write( []byte(fmt.Sprintf(`{"message":"%s"}`, msg)) )
}

// get is an api call to return all the registered listeners
func (r *Registry) get(rw http.ResponseWriter, req *http.Request) {

	var items []*W
	for i:=0; i<r.Len(); i++ {
		items = append(items, r.Get(i))
	}

	if msg, err := json.Marshal( items ); err != nil {
		jsonResponse(rw, http.StatusInternalServerError, err.Error())
	} else {
		rw.Header().Set("Content-Type", "application/json")
		rw.Write(msg)
	}
}

// parspIP returns just the ip address from "IP:port"
func parseIP(s string) (string, error) {
	ip1, _, err := net.SplitHostPort(s)
	if err == nil {
		return ip1, nil
	}<commit_msg>removing whitespace line<commit_after>package webhook

import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net"
	"net/http"
)

type Registry struct {
	UpdatableList
}

// jsonResponse is an internal convenience function to write a json response
func jsonResponse(rw http.ResponseWriter, code int, msg string) {
	rw.Header().Set("Content-Type", "application/json")
	rw.WriteHeader(code)
	rw.Write( []byte(fmt.Sprintf(`{"message":"%s"}`, msg)) )
}

// get is an api call to return all the registered listeners
func (r *Registry) get(rw http.ResponseWriter, req *http.Request) {
	var items []*W
	for i:=0; i<r.Len(); i++ {
		items = append(items, r.Get(i))
	}

	if msg, err := json.Marshal( items ); err != nil {
		jsonResponse(rw, http.StatusInternalServerError, err.Error())
	} else {
		rw.Header().Set("Content-Type", "application/json")
		rw.Write(msg)
	}
}

// parspIP returns just the ip address from "IP:port"
func parseIP(s string) (string, error) {
	ip1, _, err := net.SplitHostPort(s)
	if err == nil {
		return ip1, nil
	}
{'fraction_non_alphanumeric': 0.15825242718446603, 'fraction_numerical': 0.002912621359223301, 'mean_word_length': 4.2846153846153845, 'pattern_counts': {'":': 2, '<': 5, '<?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': '723264', 'n_tokens_mistral': 748, 'n_tokens_neox': 729, 'n_words': 204}