func ErrorHandler(
	users interface {
		GetAuthenticated(context.Context) (users.User, error)
	},
	handler func(w http.ResponseWriter, req *http.Request) error,
) http.Handler {
	if users == nil {
		users = noUsers{}
	}
	return &errorHandler{handler: handler, users: users}
}
ErrorHandler factors error handling out of the HTTP handler.
If users is nil, it treats all requests as made by an unauthenticated user.
package httputil
import (
	"compress/gzip"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
	"github.com/shurcooL/httperror"
	"github.com/shurcooL/users"
	"golang.org/x/net/http/httpguts"
)