// paramsFromHTTPRouter converts httprouter.Params to goat.Params
427765
func paramsFromHTTPRouter(hrps httprouter.Params) Params {
	var ps = Params{}

	for _, p := range hrps {
		ps[p.Key] = p.Value
	}

	return ps
}
664163
func (f *Fn) ParamList() string {
	return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
}
1093525
func (s *RouterService) NewStopRouterParams(id string) *StopRouterParams {
	p := &StopRouterParams{}
	p.p = make(map[string]interface{})
	p.p["id"] = id
	return p
}
910762
func Params(req *http.Request) ParamCol {
	if value, ok := httpcontext.GetOk(req, paramsKey); ok {
		return ParamCol(value.(map[string]string))
	}
	return ParamCol{}
}
966005
func (s *FirewallService) NewListPortForwardingRulesParams() *ListPortForwardingRulesParams {
	p := &ListPortForwardingRulesParams{}
	p.p = make(map[string]interface{})
	return p
}
1354295
func (h HTTPRouter) GetRouteParameter(r http.Request, param string) string {
	path := httprouter.CleanPath(r.URL.Path)
	_, params, _ := h.router.Lookup(r.Method, path)
	return params.ByName(param)
}
1047859
func (s *RouterService) NewListVirtualRouterElementsParams() *ListVirtualRouterElementsParams {
	p := &ListVirtualRouterElementsParams{}
	p.p = make(map[string]interface{})
	return p
}
1111846
func (c *Context) RoutesHandler(builder Builder) http.Handler {
	b := builder
	if b == nil {
		b = PassthroughBuilder
	}
	return NewRouter(c, b(NewOperationExecutor(c)))
}
527636
func NewContextParams(ctx context.Context, params httprouter.Params) context.Context {
	return context.WithValue(ctx, ctxKeyParams, params)
}
747923
func (s *TemplateService) NewUpgradeRouterTemplateParams() *UpgradeRouterTemplateParams {
	p := &UpgradeRouterTemplateParams{}
	p.p = make(map[string]interface{})
	return p
}
1363131
func (rtr *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	rtr.serveHandler(rw, req)
}
443289
func bucketNameFromReqParams(params interface{}) (string, bool) {
	if iface, ok := params.(bucketGetter); ok {
		b := iface.getBucket()
		return b, len(b) > 0
	}

	return "", false
}
510572
func (r *Request) QueryParameters(name string) []string {
	return r.Request.URL.Query()[name]
}
14879
func (h *virtualHostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	// if r.Host is not set, we can continue serving since a browser would set the Host header
	if r.Host == "" {
		h.next.ServeHTTP(w, r)
		return
	}
	host, _, err := net.SplitHostPort(r.Host)
	if err != nil {
		// Either invalid (too many colons) or no port specified
		host = r.Host
	}
	if ipAddr := net.ParseIP(host); ipAddr != nil {
		// It's an IP address, we can serve that
		h.next.ServeHTTP(w, r)
		return

	}
	// Not an ip address, but a hostname. Need to validate
	if _, exist := h.vhosts["*"]; exist {
		h.next.ServeHTTP(w, r)
		return
	}
	if _, exist := h.vhosts[host]; exist {
		h.next.ServeHTTP(w, r)
		return
	}
	http.Error(w, "invalid host specified", http.StatusForbidden)
}
245043
func (r *DynamicRouter) ServeHTTP(res http.ResponseWriter, req *http.Request) {
	w := &responseWrapper{ResponseWriter: res, status: 200, body: []byte{}}
	hj, ok := res.(http.Hijacker)
	if ok {
		w.Hijacker = hj
	}
	defer func() {
		if r := recover(); r != nil {
			// we dunno what's happened so, we set the
			// status code to 500
			w.WriteHeader(http.StatusInternalServerError)
			w.flush()
		}
	}()
	n, err := r.findEndpoint(req)
	if err != nil {
		w.WriteHeader(http.StatusNotFound)
		w.flush()
	} else if n.handler != nil {
		// we pass all filter in the right order. if one return false
		// we return, assuming that everything has been written in response
		for _, filter := range n.filters {
			if !filter(w, req) {
				w.flush()
				return
			}
		}
		n.handler(r.ctx, w, req)
		w.flush()
	}
}
819023
func MatchedRouteFrom(req *http.Request) *MatchedRoute {
	mr := req.Context().Value(ctxMatchedRoute)
	if mr == nil {
		return nil
	}
	if res, ok := mr.(*MatchedRoute); ok {
		return res
	}
	return nil
}
1258444
func Parameter(r *http.Request, key string) string {
	params, ok := r.Context().Value(contextKeyParams).(map[string]string)
	if ok { // Parameters already parsed.
		return params[key]
	}
	paramsIdx, ok := r.Context().Value(contextKeyParamsIdx).(map[string]uint16)
	if !ok {
		return ""
	}
	params = make(map[string]string, len(paramsIdx))
	parts := splitPath(r.URL.Path)
	for name, idx := range paramsIdx {
		switch name {
		case "*":
			for idx < uint16(len(parts)) {
				params[name] += parts[idx]
				if idx < uint16(len(parts))-1 {
					params[name] += "/"
				}
				idx++
			}
		default:
			params[name] = parts[idx]
		}
	}
	*r = *r.WithContext(context.WithValue(r.Context(), contextKeyParams, params))
	return params[key]
}