<commit_before>package pi

import "strings"

// route represents an API route.
// For example: /user/get/{id}
type route struct {
	RouteURL     string
	ChildRoutes  routes
	Methods      map[string]HandlerFunction
	Interceptors interceptors
}

type routes []*route

// newRoute returns a new route.
func newRoute(RouteURL string, ChildRoutes ...*route) *route {
	return &route{
		RouteURL:    RouteURL,
		ChildRoutes: ChildRoutes,
		Methods:     make(map[string]HandlerFunction),
	}
}

// Before registers an interceptor to be called before the request is handled.
func (r *route) Before(b beforeInterceptor) *route {
	r.Interceptors.addBefore(b)
	return r
}

// After registers an interceptor to be called after the request has been handled.
func (r *route) After(a afterInterceptor) *route {
	r.Interceptors.addAfter(a)
	return r
}

// Error registers an interceptor to be called when an error occurs in the request handler or in any Before interceptor.
func (r *route) Error(e errorInterceptor) *route {
	r.Interceptors.addError(e)
	return r
}

// Intercept registers an interceptor to be called before, after or on error.
func (r *route) Intercept(ci interface {}) *route {
	r.Interceptors.addInterceptor(ci)
	return r
}
<commit_msg>Added AfterFunc, ErrorFunc and BeforeFunc.<commit_after>package pi

import "strings"

// route represents an API route.
// For example: /user/get/{id}
type route struct {
	RouteURL     string
	ChildRoutes  routes
	Methods      map[string]HandlerFunction
	Interceptors interceptors
}

type routes []*route

// newRoute returns a new route.
func newRoute(RouteURL string, ChildRoutes ...*route) *route {
	return &route{
		RouteURL:    RouteURL,
		ChildRoutes: ChildRoutes,
		Methods:     make(map[string]HandlerFunction),
	}
}

type interceptorHelper struct {
	BeforeFunc HandlerFunction
	AfterFunc  HandlerFunction
	ErrorFunc  func(error) HandlerFunction
}

func (helper *interceptorHelper) Before() HandlerFunction {
	return helper.BeforeFunc
}

func (helper *interceptorHelper) After() HandlerFunction {
	return helper.AfterFunc
}

func (helper *interceptorHelper) Error(err error) HandlerFunction {
	return helper.ErrorFunc(err)
}

// Before registers an interceptor to be called before the request is handled.
func (r *route) Before(b beforeInterceptor) *route {
	r.Interceptors.addBefore(b)
	return r
}

// BeforeFunc add an an Before handler to the interceptor.
func (r *route) BeforeFunc(handler HandlerFunction) *route {
	helper := &interceptorHelper{
		BeforeFunc: handler,
	}
	r.Interceptors.addBefore(helper)
	return r
}

// After registers an interceptor to be called after the request has been handled.
func (r *route) After(a afterInterceptor) *route {
	r.Interceptors.addAfter(a)
	return r
}

// AfterFunc add an an After interceptor.
func (r *route) AfterFunc(handler HandlerFunction) *route {
	helper := &interceptorHelper{
		AfterFunc: handler,
	}
	r.Interceptors.addAfter(helper)
	return r
}

// Error registers an interceptor to be called when an error occurs in the request handler or in any Before interceptor.
func (r *route) Error(e errorInterceptor) *route {
	r.Interceptors.addError(e)
	return r
}

// ErrorFunc add an an Error interceptor.
func (r *route) ErrorFunc(handler func (error) HandlerFunction) *route {
	helper := &interceptorHelper{
		ErrorFunc: handler,
	}
	r.Interceptors.addError(helper)
	return r
}

// Intercept registers an interceptor to be called before, after or on error.
func (r *route) Intercept(ci interface{}) *route {
	r.Interceptors.addInterceptor(ci)
	return r
}

{'fraction_non_alphanumeric': 0.0911905432029271, 'fraction_numerical': 0.0, 'mean_word_length': 4.476117103235747, 'pattern_counts': {'":': 0, '<': 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': '5114380', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1076, 'n_words': 374}