func (h *httpHandler) sendError(w http.ResponseWriter, err error) {
	w.Header().Add("Content-Type", "application/json")
	w.WriteHeader(h.errorCoder(err))
	e := json.NewEncoder(w)
	e.SetEscapeHTML(false)
	e.Encode(&errorResponse{
		Message: err.Error(),
	})
}
sendError sends an error response
package kvserver
import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/adamlouis/squirrelbyte/server/pkg/model/kvmodel"
	"github.com/gorilla/mux"
	"net/http"
	"strconv"
)
type HTTPHandler interface {
	ListKVs(w http.ResponseWriter, req *http.Request)
	GetKV(w http.ResponseWriter, req *http.Request)
	PutKV(w http.ResponseWriter, req *http.Request)
	DeleteKV(w http.ResponseWriter, req *http.Request)
}
type APIHandler interface {
	ListKVs(ctx context.Context, queryParams *kvmodel.ListKVsRequest) (*kvmodel.ListKVsResponse, error)
	GetKV(ctx context.Context, pathParams *kvmodel.GetKVPathParams) (*kvmodel.KV, error)
	PutKV(ctx context.Context, pathParams *kvmodel.PutKVPathParams, body *kvmodel.KV) (*kvmodel.KV, error)
	DeleteKV(ctx context.Context, pathParams *kvmodel.DeleteKVPathParams) error
}
func RegisterRouter(apiHandler APIHandler, r *mux.Router, c ErrorCoder) {
	h := apiHandlerToHTTPHandler(apiHandler, c)
	r.Handle("/kvs", http.HandlerFunc(h.ListKVs)).Methods(http.MethodGet)
	r.Handle("/kvs/{key}", http.HandlerFunc(h.GetKV)).Methods(http.MethodGet)
	r.Handle("/kvs/{key}", http.HandlerFunc(h.PutKV)).Methods(http.MethodPut)
	r.Handle("/kvs/{key}", http.HandlerFunc(h.DeleteKV)).Methods(http.MethodDelete)
}
func apiHandlerToHTTPHandler(apiHandler APIHandler, errorCoder ErrorCoder) HTTPHandler {
	return &httpHandler{
		apiHandler: apiHandler,
		errorCoder: errorCoder,
	}
}
type httpHandler struct {
	apiHandler APIHandler
	errorCoder ErrorCoder
}
type ErrorCoder func(e error) int