func Decode(e map[string]string) *Endpoint {
	if e == nil {
		return nil
	}
	return &Endpoint{
		Name:        e["endpoint"],
		Description: e["description"],
		Method:      slice(e["method"]),
		Path:        slice(e["path"]),
		Host:        slice(e["host"]),
		Handler:     e["handler"],
	}
}
Decode decodes endpoint metadata into an endpoint
package api
import (
	"crypto/tls"
	"encoding/json"
	"errors"
	"io"
	"net/http"
	"regexp"
	"strings"
	jsonpatch "github.com/evanphx/json-patch/v5"
	"github.com/micro/micro/v3/service/api/resolver"
	"github.com/micro/micro/v3/service/context/metadata"
	"github.com/micro/micro/v3/service/registry"
	"github.com/micro/micro/v3/service/server"
	"github.com/micro/micro/v3/util/acme"
	"github.com/micro/micro/v3/util/codec"
	"github.com/micro/micro/v3/util/codec/bytes"
	"github.com/micro/micro/v3/util/codec/jsonrpc"
	"github.com/micro/micro/v3/util/codec/protorpc"
	"github.com/micro/micro/v3/util/qson"
	"github.com/oxtoacart/bpool"
)
var (
	bufferPool = bpool.NewSizedBufferPool(1024, 8)
)
type buffer struct {
	io.ReadCloser
}
func (b *buffer) Write(_ []byte) (int, error) {
	return 0, nil
}
type API interface {
	Init(...Option) error
	Options() Options
	Register(*Endpoint) error
	Deregister(*Endpoint) error
	String() string
}
type Server interface {
	Address() string
	Init(opts ...Option) error
	Handle(path string, handler http.Handler)
	Start() error
	Stop() error
}
type Options struct {
	EnableACME   bool
	EnableCORS   bool
	ACMEProvider acme.Provider
	EnableTLS    bool
	ACMEHosts    []string
	TLSConfig    *tls.Config
	Resolver     resolver.Resolver
	Wrappers     []Wrapper
}
type Option func(*Options)
type Wrapper func(h http.Handler) http.Handler
func WrapHandler(w ...Wrapper) Option {
	return func(o *Options) {
		o.Wrappers = append(o.Wrappers, w...)
	}
}
func EnableCORS(b bool) Option {
	return func(o *Options) {
		o.EnableCORS = b
	}
}
func EnableACME(b bool) Option {
	return func(o *Options) {
		o.EnableACME = b
	}
}
func ACMEHosts(hosts ...string) Option {
	return func(o *Options) {
		o.ACMEHosts = hosts
	}
}
func ACMEProvider(p acme.Provider) Option {
	return func(o *Options) {
		o.ACMEProvider = p
	}
}
func EnableTLS(b bool) Option {
	return func(o *Options) {
		o.EnableTLS = b
	}
}
func TLSConfig(t *tls.Config) Option {
	return func(o *Options) {
		o.TLSConfig = t
	}
}
func Resolver(r resolver.Resolver) Option {
	return func(o *Options) {
		o.Resolver = r
	}
}
type Endpoint struct {
	Name string
	Description string
	Handler string
	Host []string
	Method []string
	Path []string
	Body string
	Stream bool
}
type Service struct {
	Name string
	Endpoint *Endpoint
	Services []*registry.Service
}
func Encode(e *Endpoint) map[string]string {
	if e == nil {
		return nil
	}
	ep := make(map[string]string)
	set := func(k, v string) {
		if len(v) == 0 {
			return
		}
		ep[k] = v
	}
	set("endpoint", e.Name)
	set("description", e.Description)
	set("handler", e.Handler)
	set("method", strings.Join(e.Method, ","))
	set("path", strings.Join(e.Path, ","))
	set("host", strings.Join(e.Host, ","))
	return ep
}