// Handle function is entry point for all http request.
543909
func Handle(writer http.ResponseWriter, req *http.Request) {

	var (
		work Workload
		err  error
		res  Result
		body []byte
	)

	body, err = ioutil.ReadAll(req.Body)

	if err != nil {
		str := fmt.Sprintf("[Handle] Unable to read in the body of the request: %s", body)
		log.Error(str)
		http.Error(writer, str, 500)
		return
	}

	err = json.Unmarshal(body, &work)

	if err != nil {
		str := fmt.Sprintf("[ERROR] Unable to parse workload JSON: %s", err)
		http.Error(writer, str, 500)
		return
	}

	err = process(work, &res)

	if err != nil {
		str := fmt.Sprintf("[ERROR] Problems processing workload: %s", err)
		http.Error(writer, str, 500)
		return
	}

	body, _ = json.Marshal(res)
	writer.Write(body)
}
67442
func (fn UpdateTaskHandlerFunc) Handle(params UpdateTaskParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
871057
func (h *errorHandler) Handle(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	err := h.handler(ctx, w, req, store)
	if err == nil {
		return nil
	}

	gerr := goof.Newe(err)
	ctx.WithError(gerr).Error("error: api call failed")

	httpErr := goof.NewHTTPError(gerr, getStatus(err))
	if isLogAPICallErrJSON(ctx) {
		buf, err := json.Marshal(httpErr)
		if err != nil {
			ctx.WithError(err).Error(
				"error marshalling api call err to json")
		} else {
			ctx.WithField("apiErr", string(buf)).Debug("api call error json")
		}
	}

	httputils.WriteJSON(w, httpErr.Status(), httpErr)
	return nil
}
65804
func (g *routeGroup) Handle(method string, path string, h http.HandlerFunc) {
	g.handle(method, path, h)
}
190417
func (r *ChainRouter) Handle(w http.ResponseWriter, rq *http.Request, _ Collector) {
	r.ServeHTTP(w, rq)
}
244777
func (s *Server) handle(method, path string, h handlerFunc, authStrategy ...string) *route {
	r := s.route(h)
	s.mux.Handle(path, r).Methods(method)
	return r
}
893113
func (s *Server) Handle(method string, handlerFunc interface{}) {
	addHandler(s.handlers, method, handlerFunc)
}
1256731
func Handle(route string, method string, httpHandler http.Handler) {
	mainServer.Handle(route, method, httpHandler)
}
1244678
func (s *APIGroupHandler) handle(req *restful.Request, resp *restful.Response) {
	s.ServeHTTP(resp.ResponseWriter, req.Request)
}
268909
func (fn AddPetHandlerFunc) Handle(params AddPetParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
644731
func (h *basicHandler) Handle(c context.Context, conn net.Conn) {
	h.handlerFunc(c, conn)
}
756268
func (fn FindHandlerFunc) Handle(params FindParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
986385
func (h HandlerFunc) Handle(rawReq json.RawMessage, ctx *apex.Context) (interface{}, error) {
	var req Request

	if err := json.Unmarshal(rawReq, &req); err != nil {
		return nil, err
	}

	log.Printf("Request %#v", req)

	data, err := h(&req, ctx)
	resp := buildResponse(req, ctx)
	resp.Data = data

	if err != nil {
		resp.Status = "FAILURE"
		resp.Reason = err.Error()
	}

	log.Printf("Response %#v", resp)
	log.Printf("Data %#v", data)

	return data, sendResponse(resp, req.ResponseURL)
}
1101951
func (fn GetPetByIDHandlerFunc) Handle(params GetPetByIDParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
1013529
func (s *ServeMux) Handle(path string, handler http.Handler) {
	s.Route(path).Any(handler)
}
64999
func (s *Server) Handle(typ string, f protocolHandler) {
	s.handlers[typ] = f
}
557574
func (fn CreateTaskHandlerFunc) Handle(params CreateTaskParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}