// HandlersDocs returns a map from route to input and output
498971
func HandlersDocs(serverType string, services map[string]*component.Service, getPtrNames bool) (map[string]interface{}, error) {
	docs := &docs{
		Handlers: map[string]*doc{},
	}

	for serviceName, service := range services {
		for name, handler := range service.Handlers {
			routeName := route.NewRoute(serverType, serviceName, name)
			docs.Handlers[routeName.String()] = docForMethod(handler.Method, getPtrNames)
		}
	}

	return docs.Handlers.toMap()
}
591823
func (s *Server) HandleListServices(c web.C, w http.ResponseWriter, r *http.Request) {
	services, err := s.Store.List("/services/")
	if err != nil {
		s.logger.Printf("ERROR: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	json.NewEncoder(w).Encode(struct {
		Services []string `json:"services"`
	}{Services: services})
}
392997
func (d *Descriptor) HandleRead(h ReadHandler) {
	if d.value != nil {
		panic("descriptor has been configured with a static value")
	}
	d.props |= CharRead
	// d.secure |= CharRead
	d.rhandler = h
}
1220554
func (sm *ServeMux) HandlerFunc(handler func(http.ResponseWriter, *http.Request) error) http.Handler {
	if sm.recoverPanic {
		return sm.MWErrorPanic(handler)
	}
	return sm.MWError(handler)
}
278473
func (s *Server) Handle(method, path, name string, handle Handler) {
	s.router.Handle(method, path, s.hrAdapt(handle))
	s.namedRoutes[name] = path
}
1058100
func handleResponses(responses chan libhoney.Response, stats *responseStats,
	toBeResent chan event.Event, delaySending chan int,
	options GlobalOptions) {
	go logStats(stats, options.StatusInterval)

	for rsp := range responses {
		stats.update(rsp)
		logfields := logrus.Fields{
			"status_code": rsp.StatusCode,
			"body":        strings.TrimSpace(string(rsp.Body)),
			"duration":    rsp.Duration,
			"error":       rsp.Err,
			"timestamp":   rsp.Metadata.(event.Event).Timestamp,
		}
		// if this is an error we should retry sending, re-enqueue the event
		if options.BackOff && (rsp.StatusCode == 429 || rsp.StatusCode == 500) {
			logfields["retry_send"] = true
			delaySending <- 1000 / int(options.NumSenders) // back off for a little bit
			toBeResent <- rsp.Metadata.(event.Event)       // then retry sending the event
		} else {
			logfields["retry_send"] = false
		}
		logrus.WithFields(logfields).Debug("event send record received")
	}
}
991768
func GenerateHandlers() map[string]mist.HandleFunc {
	return map[string]mist.HandleFunc{
		"auth":        handleAuth,
		"ping":        handlePing,
		"subscribe":   handleSubscribe,
		"unsubscribe": handleUnsubscribe,
		"publish":     handlePublish,
		// "publishAfter":     handlePublishAfter,
		"list":    handleList,
		"listall": handleListAll, // listall related
		"who":     handleWho,     // who related
	}
}
559232
func HandlerProcess(_ *logrus.Entry, _ *CustomFormatter) (interface{}, error) {
	return os.Getpid(), nil
}
999450
func (ra *RemoteAddr) HandlerFunc(w http.ResponseWriter, r *http.Request) {
	ra.handleActualRequest(w, r)
}
233563
func (c Chain) HandlerCF(xhc HandlerFuncC) HandlerC {
	return c.HandlerC(HandlerFuncC(xhc))
}
610149
func httpHandlers(routes []*Route) map[string][]*Route {
	handlers := make(map[string][]*Route, len(validHTTPMethods))

	for _, validMethod := range validHTTPMethods {
		handlers[validMethod] = []*Route{}
	}

	for idx, route := range routes {
		found := false
		for _, validMethod := range validHTTPMethods {
			if route.Method == validMethod {
				found = true
				break
			}
		}

		if !found {
			LOGHANDLER.Fatal("Unsupported HTTP request method provided. Method:", route.Method)
			return nil
		}

		if route.Handlers == nil || len(route.Handlers) == 0 {
			LOGHANDLER.Fatal("No handlers provided for the route '", route.Pattern, "', method '", route.Method, "'")
			return nil
		}

		err := route.init()
		if err != nil {
			LOGHANDLER.Fatal("Unsupported URI pattern.", route.Pattern, err)
			return nil
		}

		checkDuplicateRoutes(idx, route, routes)

		handlers[route.Method] = append(handlers[route.Method], route)
	}

	return handlers
}
208431
func RemotesDocs(serverType string, services map[string]*component.Service, getPtrNames bool) (map[string]interface{}, error) {
	docs := &docs{
		Remotes: map[string]*doc{},
	}

	for serviceName, service := range services {
		for name, remote := range service.Remotes {
			routeName := route.NewRoute(serverType, serviceName, name)
			docs.Remotes[routeName.String()] = docForMethod(remote.Method, getPtrNames)
		}
	}

	return docs.Remotes.toMap()
}
729539
func HandleResponse(f ResponseHandler) Opt {
	return func(c *Client) Opt {
		old := c.handleResponse
		c.handleResponse = f
		return HandleResponse(old)
	}
}
679580
func (r *Router) Handler(req *http.Request) (route *Route, h Handler, vars map[string]string) {
	var match mux.RouteMatch

	if r.mux.Match(req, &match) {
		route = r.getOrCreateRoute(match.Route, "")
		h = match.Handler.(Handler)
		vars = match.Vars
		return
	}

	if r.NotFoundHandler == nil {
		h = HandlerFunc(NotFound)
		return
	}

	h = r.NotFoundHandler
	return
}
1079671
func (h *CSRFHandler) handleSuccess(w http.ResponseWriter, r *http.Request) {
	h.successHandler.ServeHTTP(w, r)
}
38680
func HandleRecover(handler Handler) {
	err := Recover(recover())
	if err != nil {
		handler.Handle(err)
	}
}
1082982
func (c *Client) handleResponseStream(resp *http.Response, ch chan *HostData) {
	reader := bufio.NewReader(resp.Body)

	for {
		banner := new(HostData)
		chunk, err := reader.ReadBytes('\n')
		if err != nil {
			resp.Body.Close()
			close(ch)
			break
		}

		chunk = bytes.TrimRight(chunk, "\n\r")
		if len(chunk) == 0 {
			continue
		}

		if err := c.parseResponse(banner, bytes.NewBuffer(chunk)); err != nil {
			resp.Body.Close()
			close(ch)
			break
		}

		ch <- banner
	}
}