func AddMetricEndpoints(r *mux.Router, env *Env) *mux.Router {
	m := r.PathPrefix("/metrics").Subrouter()
	m.Handle("/{profile}", &Endpoint{Env: env, Handler: metricsHandler})
	return m
}
AddMetricEndpoints adds the metric/debugging endpoints to the given router, and
returns an instance of the Subrouter.
package centiment
import (
	"context"
	"encoding/json"
	"fmt"
	"net/http"
	"runtime/pprof"
	"time"
	"unicode/utf8"
	"github.com/go-kit/kit/log"
	"github.com/gorilla/mux"
	"github.com/gosimple/slug"
	"github.com/pkg/errors"
)
type Env struct {
	DB       DB
	Hostname string
	Logger   log.Logger
}
type Endpoint struct {
	Env     *Env
	Handler func(*Env, http.ResponseWriter, *http.Request) error
}
type HTTPError struct {
	Code int   `json:"code"`
	Err  error `json:"error"`
}
func (he HTTPError) Error() string {
	return fmt.Sprintf("code=%d err=%s", he.Code, he.Err)
}
func (he HTTPError) JSON() ([]byte, error) {
	return json.Marshal(he)
}
func (ep *Endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if err := ep.Handler(ep.Env, w, r); err != nil {
		switch e := err.(type) {
		case HTTPError:
			w.Header().Set("Content-Type", "application/json")
			b, err := e.JSON()
			if err != nil {
				serverError(w)
			}
			w.Write(b)
		default:
			ep.Env.Logger.Log("err", err, "msg", "serverError")
			serverError(w)
		}
		return
	}
}
func AddIndexEndpoints(r *mux.Router, env *Env) *mux.Router {
	h := func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "%s\n", env.Hostname)
	}
	r.HandleFunc("/", h)
	return r
}
func AddSentimentEndpoints(r *mux.Router, env *Env) *mux.Router {
	s := r.PathPrefix("/sentiments").Subrouter()
	s.Handle("/{topicSlug}", &Endpoint{Env: env, Handler: sentimentHandler})
	s.Handle("/{topicSlug}", &Endpoint{Env: env, Handler: sentimentHandler}).
		Queries("count", "{count}")
	s.Handle("/{topicSlug}", &Endpoint{Env: env, Handler: sentimentHandler}).
		Queries("before", "{before}")
	s.Handle("/{topicSlug}", &Endpoint{Env: env, Handler: sentimentHandler}).
		Queries("after", "{after}")
	s.Handle("/{topicSlug}", &Endpoint{Env: env, Handler: sentimentHandler}).
		Queries("id", "{id}")
	return s
}