func (srv *Server) registerPost(ep *Endpoint) (err error) {
	for _, rute := range srv.routePosts {
		_, ok := rute.parse(ep.Path)
		if ok {
			return ErrEndpointAmbiguous
		}
	}
	rute, err := newRoute(ep)
	if err != nil {
		return err
	}
	srv.routePosts = append(srv.routePosts, rute)
	return nil
}
registerPost register HTTP method POST with callback to handle it.
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)
}
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
}
func (srv *Server) registerDelete(ep *Endpoint) (err error) {
	ep.RequestType = RequestTypeQuery
	for _, rute := range srv.routeDeletes {
		_, ok := rute.parse(ep.Path)
		if ok {
			return ErrEndpointAmbiguous
		}
	}
	rute, err := newRoute(ep)
	if err != nil {
		return err
	}
	srv.routeDeletes = append(srv.routeDeletes, rute)
	return nil
}
func (srv *Server) RegisterEvaluator(eval Evaluator) {
	srv.evals = append(srv.evals, eval)
}
func (srv *Server) registerGet(ep *Endpoint) (err error) {
	ep.RequestType = RequestTypeQuery
	for _, rute := range srv.routeGets {
		_, ok := rute.parse(ep.Path)
		if ok {
			return ErrEndpointAmbiguous
		}
	}
	rute, err := newRoute(ep)
	if err != nil {
		return err
	}
	srv.routeGets = append(srv.routeGets, rute)
	return nil
}
func (srv *Server) registerPatch(ep *Endpoint) (err error) {
	for _, rute := range srv.routePatches {
		_, ok := rute.parse(ep.Path)
		if ok {
			return ErrEndpointAmbiguous
		}
	}
	rute, err := newRoute(ep)
	if err != nil {
		return err
	}
	srv.routePatches = append(srv.routePatches, rute)
	return nil
}