func (srv *Server) RegisterEndpoint(ep *Endpoint) (err error) {
	if ep == nil {
		return nil
	}
	if ep.Call == nil {
		return fmt.Errorf("http.RegisterEndpoint: empty Call field")
	}
	switch ep.Method {
	case RequestMethodConnect:
		return fmt.Errorf("http.RegisterEndpoint: can't handle CONNECT method yet")
	case RequestMethodDelete:
		err = srv.registerDelete(ep)
	case RequestMethodHead:
		return nil
	case RequestMethodOptions:
		return nil
	case RequestMethodPatch:
		err = srv.registerPatch(ep)
	case RequestMethodPost:
		err = srv.registerPost(ep)
	case RequestMethodPut:
		err = srv.registerPut(ep)
	case RequestMethodTrace:
		return fmt.Errorf("http.RegisterEndpoint: can't handle TRACE method yet")
	default:
		ep.Method = RequestMethodGet
		err = srv.registerGet(ep)
	}
	return err
}
RegisterEndpoint register the Endpoint based on Method.
If Method field is not set, it will default to GET.
The Endpoint.Call field MUST be set, or it will return an error.

Endpoint with method HEAD and OPTIONS does not have any effect because it
already handled automatically by server.

Endpoint with method CONNECT and TRACE will return an error because its not
supported yet.
package http
import (
	"context"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
	"github.com/shuLhan/share/lib/debug"
	"github.com/shuLhan/share/lib/memfs"
)
const (
	defRWTimeout = 30 * time.Second
	corsWildcard = "*"
)
type Server struct {
	*http.Server
	Options *ServerOptions
	evals        []Evaluator
	routeDeletes []*route
	routeGets    []*route
	routePatches []*route
	routePosts   []*route
	routePuts    []*route
}
func NewServer(opts *ServerOptions) (srv *Server, err error) {
	opts.init()
	srv = &Server{
		Options: opts,
	}
	srv.Server = opts.Conn
	srv.Server.Addr = opts.Address
	srv.Handler = srv
	if srv.ReadTimeout == 0 {
		srv.ReadTimeout = defRWTimeout
	}
	if srv.WriteTimeout == 0 {
		srv.WriteTimeout = defRWTimeout
	}
	if opts.Development || (opts.Memfs == nil && len(opts.Root) > 0) {
		opts.Memfs, err = memfs.New(&opts.Options)
		if err != nil {
			return nil, err
		}
	}
	return srv, nil
}
func (srv *Server) RedirectTemp(res http.ResponseWriter, redirectURL string) {
	if len(redirectURL) == 0 {
		redirectURL = "/"
	}
	res.Header().Set(HeaderLocation, redirectURL)
	res.WriteHeader(http.StatusTemporaryRedirect)
}