<commit_before>package modelprovider

import (
	"encoding/json"
	"fmt"
	"github.com/gorilla/mux"
	"net/http"
)

type UserData struct {
	User string
	Data map[string]string
}

type HandlerFunction func(http.ResponseWriter, *http.Request)

type RouterProvider interface {
	GetRouter() *mux.Router
	GetHandlerFunc() HandlerFunction
}

func (c Config) GetRouter() *mux.Router {
	fmt.Println("Getting routes")
	router := mux.NewRouter()
	router.HandleFunc("/{action}", c.GetHandlerFunc())
	return router
}

func (c Config) RenderResponse(w http.ResponseWriter, r *http.Request, user UserData) {
	js, err := json.Marshal(user)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.Write(js)
	// path := r.URL.Path
	// trimmedPath := strings.TrimRight(path, "/")

	// templatePath, ok := c.TemplatesMap[trimmedPath]

	// if ok == false {
	// 	fmt.Println("Throwing template error")
	// 	return nil, errors.New("Template not found")
	// }
	// assetsDir := c.PkgDir + "/" + "assets" + "/"
	// fmt.Println(assetsDir + templatePath)
	// tmpl, err := template.ParseFiles(assetsDir + templatePath)

	// if err != nil {
	// 	fmt.Println("Going to explode now!!")
	// 	http.Redirect(w, r, "/", http.StatusFound)
	// }
	// if err = tmpl.Execute(w, pdata); err != nil {
	// 	panic(err)
	// }
}

func (c Config) GetHandlerFunc() HandlerFunction {
	return func(w http.ResponseWriter, r *http.Request) {
		// todo: abstract pagedata provider interface
		pdata := UserData{"alex", map[string]string{"name": "Aleksandr"}}
		c.RenderResponse(w, r, pdata)
	}
}<commit_msg>Added Users structure; removed commented code<commit_after>package modelprovider

import (
	"encoding/json"
	"fmt"
	"github.com/gorilla/mux"
	"net/http"
)

type UserData struct {
	User string
	Data map[string]string
}

type Users struct {
	UsersList []UserData
}

type HandlerFunction func(http.ResponseWriter, *http.Request)

type RouterProvider interface {
	GetRouter() *mux.Router
	GetHandlerFunc() HandlerFunction
}

func (c Config) GetRouter() *mux.Router {
	fmt.Println("Getting routes")
	router := mux.NewRouter()
	router.HandleFunc("/{action}", c.GetHandlerFunc())
	return router
}

func (c Config) RenderResponse(w http.ResponseWriter, r *http.Request, users Users) {
	js, err := json.Marshal(users)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.Write(js)
}

func (c Config) GetHandlerFunc() HandlerFunction {
	return func(w http.ResponseWriter, r *http.Request) {
		// todo: abstract pagedata provider interface
		users := make([]UserData, 1)
		users[0] = UserData{"alex", map[string]string{"name": "Aleksandr"}}
		c.RenderResponse(w, r, Users{users})
	}
}
{'fraction_non_alphanumeric': 0.1571632216678546, 'fraction_numerical': 0.0007127583749109052, 'mean_word_length': 4.398076923076923, 'pattern_counts': {'":': 2, '<': 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': '2785111', 'n_tokens_mistral': 997, 'n_tokens_neox': 967, 'n_words': 221}