func (e *Endpoints) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	var endpoint *Endpoint
	switch req.Method {
	case "DELETE":
		endpoint = e.Delete
	case "HEAD":
		endpoint = e.Head
	case "GET":
		endpoint = e.Get
	case "OPTIONS":
		endpoint = e.Options
	case "POST":
		endpoint = e.Post
	case "PUT":
		endpoint = e.Put
	case "PATCH":
		endpoint = e.Patch
	case "TRACE":
		endpoint = e.Trace
	case "CONNECT":
		endpoint = e.Connect
	}
	if endpoint == nil || endpoint.Handler == nil {
		w.WriteHeader(http.StatusNotFound)
		return
	}
	switch v := endpoint.Handler.(type) {
	case func(w http.ResponseWriter, req *http.Request):
		v(w, req)
	case http.HandlerFunc:
		v(w, req)
	case http.Handler:
		v.ServeHTTP(w, req)
	default:
		w.WriteHeader(http.StatusInternalServerError)
		io.WriteString(w, "Handler is not a standard http handler")
	}
}
ServeHTTP allows endpoints to serve itself using the builtin http mux
package swagger
import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"path"
	"reflect"
	"strings"
	"sync"
)
type Object struct {
	IsArray    bool                `json:"-"`
	GoType     reflect.Type        `json:"-"`
	Name       string              `json:"-"`
	Type       string              `json:"type"`
	Format     string              `json:"format,omitempty"`
	Required   []string            `json:"required,omitempty"`
	Properties map[string]Property `json:"properties,omitempty"`
}
type Property struct {
	GoType      reflect.Type `json:"-"`
	Type        string       `json:"type,omitempty"`
	Description string       `json:"description,omitempty"`
	Enum        []string     `json:"enum,omitempty"`
	Format      string       `json:"format,omitempty"`
	Ref         string       `json:"$ref,omitempty"`
	Example     string       `json:"example,omitempty"`
	Items       *Items       `json:"items,omitempty"`
}
type Contact struct {
	Email string `json:"email,omitempty"`
}
type License struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}
type Info struct {
	Description    string  `json:"description,omitempty"`
	Version        string  `json:"version,omitempty"`
	TermsOfService string  `json:"termsOfService,omitempty"`
	Title          string  `json:"title,omitempty"`
	Contact        Contact `json:"contact"`
	License        License `json:"license"`
}
type SecurityScheme struct {
	Type             string            `json:"type"`
	Description      string            `json:"description,omitempty"`
	Name             string            `json:"name,omitempty"`
	In               string            `json:"in,omitempty"`
	Flow             string            `json:"flow,omitempty"`
	AuthorizationURL string            `json:"authorizationUrl,omitempty"`
	TokenURL         string            `json:"tokenUrl,omitempty"`
	Scopes           map[string]string `json:"scopes,omitempty"`
}
type SecuritySchemeOption func(securityScheme *SecurityScheme)
func SecuritySchemeDescription(description string) SecuritySchemeOption {
	return func(securityScheme *SecurityScheme) {
		securityScheme.Description = description
	}
}
func BasicSecurity() SecuritySchemeOption {
	return func(securityScheme *SecurityScheme) {
		securityScheme.Type = "basic"
	}
}
func APIKeySecurity(name, in string) SecuritySchemeOption {
	if in != "header" && in != "query" {
		panic(fmt.Errorf(`APIKeySecurity "in" parameter must be one of: "header" or "query"`))
	}
	return func(securityScheme *SecurityScheme) {
		securityScheme.Type = "apiKey"
		securityScheme.Name = name
		securityScheme.In = in
	}
}
func OAuth2Scope(scope, description string) SecuritySchemeOption {
	return func(securityScheme *SecurityScheme) {
		if securityScheme.Scopes == nil {
			securityScheme.Scopes = map[string]string{}
		}
		securityScheme.Scopes[scope] = description
	}
}
func OAuth2Security(flow, authorizationURL, tokenURL string) SecuritySchemeOption {
	return func(securityScheme *SecurityScheme) {
		securityScheme.Type = "oauth2"
		securityScheme.Flow = flow
		securityScheme.AuthorizationURL = authorizationURL
		securityScheme.TokenURL = tokenURL
		if securityScheme.Scopes == nil {
			securityScheme.Scopes = map[string]string{}
		}
	}
}
type Endpoints struct {
	Delete  *Endpoint `json:"delete,omitempty"`
	Head    *Endpoint `json:"head,omitempty"`
	Get     *Endpoint `json:"get,omitempty"`
	Options *Endpoint `json:"options,omitempty"`
	Post    *Endpoint `json:"post,omitempty"`
	Put     *Endpoint `json:"put,omitempty"`
	Patch   *Endpoint `json:"patch,omitempty"`
	Trace   *Endpoint `json:"trace,omitempty"`
	Connect *Endpoint `json:"connect,omitempty"`
}