func HttpNotImplemented(ctx context.Context, error errors.Error) *HttpError {
	return MakeHttpError(ctx, error, http.StatusNotImplemented)
}
HttpNotFound returns an HTTP not found error
package rpc
import (
	"context"
	"fmt"
	"net/http"
	"runtime/debug"
	"strconv"
	"github.com/oasislabs/oasis-gateway/errors"
	"github.com/oasislabs/oasis-gateway/log"
	"github.com/oasislabs/oasis-gateway/rw"
	"github.com/oasislabs/oasis-gateway/stats"
	stderr "github.com/pkg/errors"
	"github.com/rs/cors"
)
const HttpHeaderTraceID = "X-OASIS-TRACE-ID"
type HttpPreProcessor interface {
	ServeHTTP(w http.ResponseWriter, req *http.Request) (bool, *http.Request)
}
type HttpMiddleware interface {
	ServeHTTP(req *http.Request) (interface{}, error)
}
type HttpMiddlewareFunc func(req *http.Request) (interface{}, error)
func (f HttpMiddlewareFunc) ServeHTTP(req *http.Request) (interface{}, error) {
	return f(req)
}
type HttpError struct {
	Cause *errors.Error
	StatusCode int
}
func (e HttpError) Log(fields log.Fields) {
	fields.Add("status_code", e.StatusCode)
	if e.Cause != nil {
		e.Cause.Log(fields)
	}
}
func (e HttpError) Error() string {
	return fmt.Sprintf("%s with status code %d", e.Cause.Error(), e.StatusCode)
}
func MakeHttpError(ctx context.Context, error errors.Error, statusCode int) *HttpError {
	return &HttpError{
		Cause:      &error,
		StatusCode: statusCode,
	}
}
func HttpBadRequest(ctx context.Context, error errors.Error) *HttpError {
	return MakeHttpError(ctx, error, http.StatusBadRequest)
}
func HttpForbidden(ctx context.Context, error errors.Error) *HttpError {
	return MakeHttpError(ctx, error, http.StatusForbidden)
}
func HttpNotFound(ctx context.Context, error errors.Error) *HttpError {
	return MakeHttpError(ctx, error, http.StatusNotFound)
}
func HttpMethodNotAllowed(ctx context.Context, error errors.Error) *HttpError {
	return MakeHttpError(ctx, error, http.StatusMethodNotAllowed)
}
func HttpTooManyRequests(ctx context.Context, error errors.Error) *HttpError {
	return MakeHttpError(ctx, error, http.StatusTooManyRequests)
}