<commit_before>package handlers

import (
	"encoding/json"
	"github.com/vgheri/goCacheIt/Godeps/_workspace/src/github.com/gorilla/mux"
	"github.com/vgheri/goCacheIt/splay"
	//"log"
	"net/http"
)

// Handler is a strictly typed object containing the list of available handlers
type Handler struct {
	HandleGetValue func(w http.ResponseWriter, r *http.Request)
	HandleAddValue func(w http.ResponseWriter, r *http.Request)
}

const mimeTypeJSON string = "application/json; charset=UTF-8"

var dataStore *splay.Tree

// New initializes the package with the underlying data store instance
func New(store *splay.Tree) *Handler {
	dataStore = store
	handler := &Handler{
		HandleGetValue: getValue,
		HandleAddValue: addValue,
	}
	return handler
}

// KeyValueCouple models the input data for the POST request
type KeyValueCouple struct {
	Key   string    //`json:"key"`
	Value splay.Any //`json:"value"`
}

// APIError models the error object sent back to the client on error
type APIError struct {
	Code    int
	Message string
}

// getValue retrieves a value by key from the datastore
func getValue(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	key := vars["key"]
	node, err := dataStore.Get(key)<commit_msg>Added json comments for APIError struct<commit_after>package handlers

import (
	"encoding/json"
	"github.com/vgheri/goCacheIt/Godeps/_workspace/src/github.com/gorilla/mux"
	"github.com/vgheri/goCacheIt/splay"
	//"log"
	"net/http"
)

// Handler is a strictly typed object containing the list of available handlers
type Handler struct {
	HandleGetValue func(w http.ResponseWriter, r *http.Request)
	HandleAddValue func(w http.ResponseWriter, r *http.Request)
}

const mimeTypeJSON string = "application/json; charset=UTF-8"

var dataStore *splay.Tree

// New initializes the package with the underlying data store instance
func New(store *splay.Tree) *Handler {
	dataStore = store
	handler := &Handler{
		HandleGetValue: getValue,
		HandleAddValue: addValue,
	}
	return handler
}

// KeyValueCouple models the input data for the POST request
type KeyValueCouple struct {
	Key   string    //`json:"key"`
	Value splay.Any //`json:"value"`
}

// APIError models the error object sent back to the client on error
type APIError struct {
	Code    int    //`json:"code"`
	Message string //`json:"message"`
}

// getValue retrieves a value by key from the datastore
func getValue(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	key := vars["key"]
	node, err := dataStore.Get(key)
{'fraction_non_alphanumeric': 0.10606060606060606, 'fraction_numerical': 0.0007974481658692185, 'mean_word_length': 4.326963906581741, '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': '2444262', 'n_tokens_mistral': 828, 'n_tokens_neox': 810, 'n_words': 252}