<commit_before>package main

import (
	"fmt"
	"net/http"
)

type Context struct {
	*Injector
	handlers      []Handler
	routerHandler Handler
	index         int
}

func (c *Context) Next() {
	c.index += 1
	c.Run()
}

func (c *Context) Run() {
	// Run all Duck handles
	for c.index < len(c.handlers) {

		if ret, err := c.Invoke(c.handlers[c.index]); err == nil {
			if len(ret) != 0 {
				rv := c.Get(c.GetType((*http.ResponseWriter)(nil)))
				res := rv.Interface().(http.ResponseWriter)
				fmt.Fprintf(res, ret[0].Interface().(string))
			}
		} else {
			fmt.Println(err)
		}
		c.index++
	}
	// Run all route handles
	if c.index == len(c.handlers) {
		c.Invoke(c.routerHandler)
	}
}

type RouterContext struct {
	*Injector
	handlers []Handler // all route handler
	index    int
}

func (rc *RouterContext) Run() {
	for i := 0; i < len(rc.handlers); i++ {
		if ret, err := rc.Invoke(rc.handlers[i]); err == nil {
			if len(ret) != 0 {
				rv := rc.Get(rc.GetType((*http.ResponseWriter)(nil)))
				res := rv.Interface().(http.ResponseWriter)
				fmt.Fprintf(res, ret[0].Interface().(string))
			}
		} else {
			fmt.Println(err)
		}
	}
}<commit_msg>Add return handler<commit_after>package main

import (
	"fmt"
	"net/http"
	"reflect"
)

type Context struct {
	*Injector
	handlers      []Handler
	routerHandler Handler
	index         int
}

func (c *Context) Next() {
	c.index += 1
	c.Run()
}

func (c *Context) Run() {
	// Run all Duck handles
	for c.index < len(c.handlers) {
		if val, err := c.Invoke(c.handlers[c.index]); err != nil {
			ReturnHandler(val, c)
		}
		c.index++
	}
	// Run all route handles
	if c.index == len(c.handlers) {
		c.Invoke(c.routerHandler)
	}
}

type RouterContext struct {
	*Injector
	handlers []Handler // all route handler
	index    int
}

type Contexter interface {
	GetType(interface{}) reflect.Type
	Get(reflect.Type) reflect.Value
}

func (rc *RouterContext) Run() {
	for i := 0; i < len(rc.handlers); i++ {
		if val, err := rc.Invoke(rc.handlers[i]); err == nil {
			ReturnHandler(val, rc)
		} else {
			fmt.Println(err)
		}
	}
}

func ReturnHandler(val []reflect.Value, c Contexter) {
	rv := c.Get(c.GetType((*http.ResponseWriter)(nil)))
	res := rv.Interface().(http.ResponseWriter)
	if len(val) == 1 {
		fmt.Fprintf(res, val[0].Interface().(string))
	} else if len(val) == 2 {
		// status code
		res.WriteHeader(int(val[0].Int()))
		fmt.Fprintf(res, val[1].Interface().(string))
	}
}
{'fraction_non_alphanumeric': 0.17637339942172656, 'fraction_numerical': 0.0053696819496076, 'mean_word_length': 3.2195121951219514, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6106014', 'n_tokens_mistral': 999, 'n_tokens_neox': 933, 'n_words': 211}