func GetParams(r *http.Request) (Params, bool) {
	return fromContext(r.Context())
}
GetParams returns params stored in the request.
package sariaf
import (
	"context"
	"net/http"
	"strings"
)
var methods = map[string]string{
	"GET":    http.MethodGet,
	"POST":   http.MethodPost,
	"PUT":    http.MethodPut,
	"DELETE": http.MethodDelete,
	"PATCH":  http.MethodPatch,
	"HEAD":   http.MethodHead,
}
type node struct {
	path     string
	key      string
	children map[string]*node
	handler  http.HandlerFunc
	param    string
}
func (n *node) add(path string, handler http.HandlerFunc) {
	current := n
	trimmed := strings.TrimPrefix(path, "/")
	slice := strings.Split(trimmed, "/")
	for _, k := range slice {
		var param string
		if len(k) > 1 && string(k[0]) == ":" {
			param = strings.TrimPrefix(k, ":")
			k = "*"
		}
		next, ok := current.children[k]
		if !ok {
			next = &node{
				path:     path,
				key:      k,
				children: make(map[string]*node),
				param:    param,
			}
			current.children[k] = next
		}
		current = next
	}
	current.handler = handler
}
func (n *node) find(path string) (*node, Params) {
	params := make(Params)
	current := n
	trimmed := strings.TrimPrefix(path, "/")
	slice := strings.Split(trimmed, "/")
	for _, k := range slice {
		var next *node
		next, ok := current.children[k]
		if !ok {
			next, ok = current.children["*"]
			if !ok {
				return nil, params
			}
		}
		current = next
		if current.param != "" {
			params[current.param] = k
		}
	}
	return current, params
}
type panicHandlerType func(w http.ResponseWriter, req *http.Request, err interface{})
type contextKeyType struct{}
type Params map[string]string
var contextKey = contextKeyType{}
func newContext(ctx context.Context, params Params) context.Context {
	return context.WithValue(ctx, contextKey, params)
}
func fromContext(ctx context.Context) (Params, bool) {
	values, ok := ctx.Value(contextKey).(Params)
	return values, ok
}
type Router struct {
	trees map[string]*node
	middlewares []func(http.HandlerFunc) http.HandlerFunc
	notFound http.HandlerFunc
	panicHandler panicHandlerType
}
func New() *Router {
	return &Router{
		trees: make(map[string]*node),
	}
}
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	if r.panicHandler != nil {
		defer func() {
			if err := recover(); err != nil {
				r.panicHandler(w, req, err)
			}
		}()
	}
	if _, ok := r.trees[req.Method]; !ok {
		http.NotFound(w, req)
		return
	}
	node, params := r.trees[req.Method].find(req.URL.Path)
	if node != nil {
		if len(params) != 0 {
			ctx := newContext(req.Context(), params)
			req = req.WithContext(ctx)
		}
		var handler = node.handler
		for _, middleware := range r.middlewares {
			handler = middleware(handler)
		}
		handler(w, req)
		return
	}
	if r.notFound != nil {
		r.notFound(w, req)
	} else {
		http.NotFound(w, req)
	}
}
func (r *Router) Handle(method string, path string, handler http.HandlerFunc) {
	if _, ok := methods[method]; !ok {
		panic("method is not valid")
	}
	if handler == nil {
		panic("handle must not be nil")
	}
	if _, ok := r.trees[method]; !ok {
		r.trees[method] = &node{
			path:     "/",
			children: make(map[string]*node),
		}
	}
	r.trees[method].add(path, handler)
}