func (t *trie) Insert(pattern string, options ...InsertOption) {
	if pattern == "" {
		panic("muxie/trie#Insert: empty pattern")
	}
	n := t.insert(pattern, "", nil, nil)
	for _, opt := range options {
		opt(n)
	}
}
Insert adds a node to the trie.
package edge
import (
	"github.com/ronaksoft/rony"
	"sort"
	"strings"
)
type RestHandler func(conn rony.RestConn, ctx *DispatchCtx) error
type RestProxy interface {
	ClientMessage(conn rony.RestConn, ctx *DispatchCtx) error
	ServerMessage(conn rony.RestConn, ctx *DispatchCtx) error
}
type restProxy struct {
	cm RestHandler
	sm RestHandler
}
func (r *restProxy) ClientMessage(conn rony.RestConn, ctx *DispatchCtx) error {
	return r.cm(conn, ctx)
}
func (r *restProxy) ServerMessage(conn rony.RestConn, ctx *DispatchCtx) error {
	return r.sm(conn, ctx)
}
func NewRestProxy(onClientMessage, onServerMessage RestHandler) *restProxy {
	return &restProxy{
		cm: onClientMessage,
		sm: onServerMessage,
	}
}
type restMux struct {
	routes map[string]*trie
}
func (hp *restMux) Set(method, path string, f RestProxy) {
	method = strings.ToUpper(method)
	if hp.routes == nil {
		hp.routes = make(map[string]*trie)
	}
	if _, ok := hp.routes[method]; !ok {
		hp.routes[method] = &trie{
			root:            newTrieNode(),
			hasRootWildcard: false,
		}
	}
	hp.routes[method].Insert(path, WithTag(method), WithProxyFactory(f))
}
func (hp *restMux) Search(conn rony.RestConn) RestProxy {
	r := hp.routes[strings.ToUpper(conn.Method())]
	if r == nil {
		return nil
	}
	n := r.Search(conn.Path(), conn)
	if n == nil {
		return nil
	}
	return n.Proxy
}
const (
	paramStart = ":"
	wildcardParamStart = "*"
)
type trie struct {
	root *trieNode
	hasRootWildcard bool
	hasRootSlash bool
}
type InsertOption func(*trieNode)
func WithProxyFactory(proxy RestProxy) InsertOption {
	if proxy == nil {
		panic("muxie/WithProxy: empty handler")
	}
	return func(n *trieNode) {
		if n.Proxy == nil {
			n.Proxy = proxy
		}
	}
}
func WithTag(tag string) InsertOption {
	return func(n *trieNode) {
		if n.Tag == "" {
			n.Tag = tag
		}
	}
}