<commit_before>package main

import (
	"fmt"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
)

const proxyHost = "https://api.github.com/"

func main() {
	port := os.Getenv("PORT")

	if port == "" {
		log.Fatal("$PORT must be set")
	}
	
	http.HandleFunc("/", ProxyFunc)
	http.ListenAndServe(":" + port, nil)
}

func ProxyFunc(w http.ResponseWriter, r *http.Request) {
	u, err := url.Parse(proxyHost)
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	token := os.Getenv("AUTH_TOKEN")
	if token != "" {
		r.Header.Set("Authorization", fmt.Sprintf("token %s", os.Getenv("AUTH_TOKEN")))
	}
	
	ua := os.Getenv("USER_AGENT")
	if ua == "" {
		ua = "github-api-reverse-proxy"
	}
	r.Header.Set("User-Agent", os.Getenv("USER_AGENT"))
	
	r.Header.Set("Pragma", "no-cache")

	proxy := httputil.NewSingleHostReverseProxy(u)
	proxy.ServeHTTP(w, r)
}<commit_msg>Better env handling<commit_after>package main

import (
	"fmt"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
)

const proxyHost = "https://api.github.com/"

func main() {
	port := os.Getenv("PORT")

	if port == "" {
		log.Fatal("$PORT must be set")
	}
	
	http.HandleFunc("/", ProxyFunc)
	http.ListenAndServe(":" + port, nil)
}

func ProxyFunc(w http.ResponseWriter, r *http.Request) {
	u, err := url.Parse(proxyHost)
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	if token, exists := os.LookupEnv("AUTH_TOKEN"); exists {
		r.Header.Set("Authorization", fmt.Sprintf("token %s", token))
	}
	
	if ua, exists := os.LookupEnv("USER_AGENT"); exists {
		r.Header.Set("User-Agent", ua)
	} else {
		r.Header.Set("User-Agent", "github-api-reverse-proxy")
	}
	
	r.Header.Set("Pragma", "no-cache")

	proxy := httputil.NewSingleHostReverseProxy(u)
	proxy.ServeHTTP(w, r)
}
{'fraction_non_alphanumeric': 0.20125427594070697, 'fraction_numerical': 0.0, 'mean_word_length': 3.9857954545454546, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2686026', 'n_tokens_mistral': 741, 'n_tokens_neox': 710, 'n_words': 129}