func MethodNotAllowed(requested string, allow []string) Error {
	msg := fmt.Sprintf("method %s is not allowed, but [%s] are", requested, strings.Join(allow, ","))
	return &MethodNotAllowedError{code: http.StatusMethodNotAllowed, Allowed: allow, message: msg}
}
MethodNotAllowed creates a new method not allowed error
package errors
import (
	"encoding/json"
	"fmt"
	"net/http"
	"strings"
)
type Error interface {
	error
	Code() int32
}
type apiError struct {
	code    int32
	message string
}
func (a *apiError) Error() string {
	return a.message
}
func (a *apiError) Code() int32 {
	return a.code
}
func New(code int32, message string, args ...interface{}) Error {
	if len(args) > 0 {
		return &apiError{code, fmt.Sprintf(message, args...)}
	}
	return &apiError{code, message}
}
func NotFound(message string, args ...interface{}) Error {
	if message == "" {
		message = "Not found"
	}
	return New(http.StatusNotFound, fmt.Sprintf(message, args...))
}
func NotImplemented(message string) Error {
	return New(http.StatusNotImplemented, message)
}
type MethodNotAllowedError struct {
	code    int32
	Allowed []string
	message string
}
func (m *MethodNotAllowedError) Error() string {
	return m.message
}
func (m *MethodNotAllowedError) Code() int32 {
	return m.code
}
func errorAsJSON(err Error) []byte {
	b, _ := json.Marshal(struct {
		Code    int32  `json:"code"`
		Message string `json:"message"`
	}{err.Code(), err.Error()})
	return b
}
func flattenComposite(errs *CompositeError) *CompositeError {
	var res []error
	for _, er := range errs.Errors {
		switch e := er.(type) {
		case *CompositeError:
			if len(e.Errors) > 0 {
				flat := flattenComposite(e)
				if len(flat.Errors) > 0 {
					res = append(res, flat.Errors...)
				}
			}
		default:
			if e != nil {
				res = append(res, e)
			}
		}
	}
	return CompositeValidationError(res...)
}