<commit_before>package fur

import (
	"net/http"
	"sync"
)

var (
	mut     sync.RWMutex
	context = make(map[*http.Request]map[interface{}]interface{})
)

func Set(req *http.Request, key, value interface{}) {
	mut.Lock()
	if context[req] != nil {
		context[req][key] = value
	} else {
		context[req] = make(map[interface{}]interface{})
		context[req][key] = value
	}
	mut.Unlock()
}

func Get(req *http.Request, key interface{}) interface{} {
	mut.RLock()
	if context[req] != nil {
		return context[req][key]
	}
	mut.RUnlock()
	return nil
}

func Delete(req *http.Request, key interface{}) {
	mut.Lock()
	if context[req] != nil {
		delete(context[req], key)
	}
	mut.Unlock()
}

func Destroy(req *http.Request) {
	delete(context, req)
}<commit_msg>Modified the context.go file, now using a struct<commit_after>package fur

import (
	"net/http"
	"sync"
)

// Context struct, req = the *http.Request provided with the NewContext func
type Context struct {
	req  *http.Request
	vars map[interface{}]interface{}
}

var (
	mutex sync.RWMutex
	memo  = make(map[*http.Request]Context)
)

// Create a new context struct, with vars map
func NewContext(req *http.Request) *Context {
	memo[req] = Context{req, make(map[interface{}]interface{})}
	c := memo[req]
	return &c
}

// Retrive a context from the memo map and return.
func FindContext(req *http.Request) *Context {
	con := memo[req]
	return &con
}

// Set a new key value pair in the context.Vars
func (c *Context) Set(key, value interface{}) {
	mutex.Lock()
	c.vars[key] = value
	mutex.Unlock()
}

// Get a key value from a context
func (c *Context) Get(key interface{}) interface{} {
	return c.vars[key]
}

// Get the map of data of the context
func (c *Context) GetAll() map[interface{}]interface{} {
	return c.vars
}

// Delete a key
func (c *Context) Delete(key interface{}) {
	delete(c.vars, key)
}

// Remove a Context from the memo map
func (c *Context) Destroy() {
	delete(memo, c.req)
}
{'fraction_non_alphanumeric': 0.15352910870685213, 'fraction_numerical': 0.0, 'mean_word_length': 4.151193633952254, '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': '2514430', 'n_tokens_mistral': 696, 'n_tokens_neox': 692, 'n_words': 202}