<commit_before>package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/dimfeld/httptreemux"
	"github.com/justinas/alice"
	"github.com/rs/xlog"
)

// App application
type App struct {
	Name string
}

func NewIHandler(h http.HandlerFunc) InternalHandler {}

// InternalHandler internal
type InternalHandler struct {
	h func(w http.ResponseWriter, r *http.Request)
}

// ServeHTTP serve
func (ih InternalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	ih.h(w, r)
	return
}

func (app *App) hello(w http.ResponseWriter, r *http.Request) {
	l := xlog.FromRequest(r)
	l.Info("hello handler")
	log.Println("this is usual logger")
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, "hello")
	return
}

func main() {
	host, _ := os.Hostname()
	conf := xlog.Config{
		Fields: xlog.F{
			"role": "my-service",
			"host": host,
		},
		Output: xlog.NewOutputChannel(xlog.NewConsoleOutput()),
	}

	c := alice.New(
		xlog.NewHandler(conf),
		xlog.MethodHandler("method"),
		xlog.URLHandler("url"),
		xlog.UserAgentHandler("user_agent"),
		xlog.RefererHandler("referer"),
		xlog.RequestIDHandler("req_id", "Request-Id"),
		accessLoggingMiddleware,
	)
	app := App{Name: "my-service"}
	router := httptreemux.New()
	r := router.NewGroup("/api").UsingContext()
	// r.GET("/hello", c.Then(InternalHandler{h: app.hello}))
	// r.GET("/hello", http.HandlerFunc(c.Then(InternalHandler{h: app.hello})))
	h := c.Then(InternalHandler{h: app.hello})
	r.GET("/hello", http.HandlerFunc(h.ServeHTTP))

	xlog.Info("xlog")
	xlog.Infof("chain: %+v", c)
	log.Println("start server")
	if err := http.ListenAndServe(":8080", router); err != nil {
		log.Fatal(err)
	}
}<commit_msg>Update handler registration<commit_after>package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/dimfeld/httptreemux"
	"github.com/justinas/alice"
	"github.com/rs/xlog"
)

// App application
type App struct {
	Name string
}

// InternalHandler internal
type InternalHandler struct {
	h func(w http.ResponseWriter, r *http.Request)
}

// ServeHTTP serve
func (ih InternalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	ih.h(w, r)
	return
}

func (app *App) hello(w http.ResponseWriter, r *http.Request) {
	l := xlog.FromRequest(r)
	l.Info("hello handler")
	log.Println("this is usual logger")
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, "hello")
	return
}

func f(h http.Handler) http.HandlerFunc {
	return http.HandlerFunc(h.ServeHTTP)
}

func main() {
	host, _ := os.Hostname()
	conf := xlog.Config{
		Fields: xlog.F{
			"role": "my-service",
			"host": host,
		},
		Output: xlog.NewOutputChannel(xlog.NewConsoleOutput()),
	}

	c := alice.New(
		xlog.NewHandler(conf),
		xlog.MethodHandler("method"),
		xlog.URLHandler("url"),
		xlog.UserAgentHandler("user_agent"),
		xlog.RefererHandler("referer"),
		xlog.RequestIDHandler("req_id", "Request-Id"),
		accessLoggingMiddleware,
	)
	app := App{Name: "my-service"}
	router := httptreemux.New()
	r := router.NewGroup("/api").UsingContext()
	// r.GET("/hello", c.Then(InternalHandler{h: app.hello}))
	// r.GET("/hello", http.HandlerFunc(c.Then(InternalHandler{h: app.hello})))
	// h := c.Then(InternalHandler{h: app.hello})
	// r.GET("/hello", http.HandlerFunc(h.ServeHTTP))
	// r.GET("/hello", f(c.Then(InternalHandler{h: app.hello})))
	r.GET("/hello", c.Then(InternalHandler{h: app.hello}).ServeHTTP)

	xlog.Info("xlog")
	xlog.Infof("chain: %+v", c)
	log.Println("start server")
	if err := http.ListenAndServe(":8080", router); err != nil {
		log.Fatal(err)
	}
}
{'fraction_non_alphanumeric': 0.182181610508281, 'fraction_numerical': 0.002284408909194746, 'mean_word_length': 4.595846645367412, 'pattern_counts': {'":': 6, '<': 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': '1390975', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1342, 'n_words': 244}