<commit_before>package main

import (
	"bytes"
	"crypto/tls"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"

	"github.com/sger/go-apns2/certificate"
	"github.com/sger/go-apns2/client"
)

func main() {

	var deviceToken = "<KEY>"
	var filename = "certs/PushChatKey.p12"
	var password = "<PASSWORD>"

	// POST URL
	url := fmt.Sprintf("%v/3/device/%v", client.Development, deviceToken)

	// Setup payload must contains an aps root label and alert message
	payload := []byte(`{ "aps" : { "alert" : "Hello world" } }`)

	cert, key, err := p12.ReadFile(filename, password)
	if err != nil {
		log.Fatal(err)
	}

	certificate := tls.Certificate{
		Certificate: [][]byte{cert.Raw},
		PrivateKey:  key,
		Leaf:        cert,
	}

	// Config
	/*config := &tls.Config{
		Certificates: []tls.Certificate{t},
	}

	config.BuildNameToCertificate()
	transport := &http.Transport{TLSClientConfig: config}

	if err := http2.ConfigureTransport(transport); err != nil {
		log.Fatal(err)
	}

	// Create http client with Transport with Go 1.6 Transport supports HTTP/2
	client := &http.Client{Transport: transport}
	//*/

	// Setup a new http client
	client, err := client.NewClient(certificate)

	if err != nil {
		log.Fatal(err)
	}

	// Sending the request with valid PAYLOAD (must starts with aps)
	req, err := http.NewRequest("POST", url, bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}

	// Send JSON Header
	// TODO
	req.Header.Set("Content-Type", "application/json")

	// Do the request
	resp, err := client.HTTPClient.Do(req)

	if err != nil {
		log.Fatal(err)
	}

	defer resp.Body.Close()
<commit_msg>refactor<commit_after>package main

import (
	"bytes"
	"crypto/tls"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"

	"github.com/sger/go-apns2/certificate"
	"github.com/sger/go-apns2/client"
)

func main() {

	var deviceToken = "<KEY>"
	var filename = "certs/PushChatKey.p12"
	var password = "<PASSWORD>"

	// POST URL
	url := fmt.Sprintf("%v/3/device/%v", client.Development, deviceToken)

	// Setup payload must contains an aps root label and alert message
	payload := []byte(`{ "aps" : { "alert" : "Hello world" } }`)

	cert, key, err := p12.ReadFile(filename, password)
	if err != nil {
		log.Fatal(err)
	}

	certificate := tls.Certificate{
		Certificate: [][]byte{cert.Raw},
		PrivateKey:  key,
		Leaf:        cert,
	}

	// Setup a new http client
	client, err := client.NewClient(certificate)

	if err != nil {
		log.Fatal(err)
	}

	// Sending the request with valid PAYLOAD (must starts with aps)
	req, err := http.NewRequest("POST", url, bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}

	// Send JSON Header
	// TODO
	req.Header.Set("Content-Type", "application/json")

	// Do the request
	resp, err := client.HTTPClient.Do(req)

	if err != nil {
		log.Fatal(err)
	}

	defer resp.Body.Close()

{'fraction_non_alphanumeric': 0.16107142857142856, 'fraction_numerical': 0.0064285714285714285, 'mean_word_length': 3.488782051282051, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4463778', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1018, 'n_words': 251}