// Handle executing the request and returning a response
179414
func (fn PetGetHandlerFunc) Handle(params PetGetParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
291495
func (mux *Mux) Handle(ctx *Context, res *http.Response, err error) {
	mux.mu.RLock()
	defer mux.mu.RUnlock()
	if err != nil {
		// Find a matching error handler
		if h, ok := mux.errm[err]; ok {
			h.Handle(ctx, res, err)
			return
		}
		if h, ok := mux.errm[nil]; ok {
			h.Handle(ctx, res, err)
			return
		}
	} else {
		// Find a matching response handler
		var h Handler
		var n = -1
		for r := range mux.res {
			if ok, cnt := r.match(res); ok {
				if cnt > n {
					h, n = r.h, cnt
				}
			}
		}
		if h != nil {
			h.Handle(ctx, res, err)
			return
		}
	}
	mux.DefaultHandler.Handle(ctx, res, err)
}
1105643
func (c *UsergroupsCreateCall) Handle(handle string) *UsergroupsCreateCall {
	c.handle = handle
	return c
}
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)
}
1363244
func Handle(handler Handler, err error) {
	if err != nil {
		handler.Handle(err)
	}
}
471131
func (h *putStatusProbe) Handle(params PutStatusProbeParams) middleware.Responder {
	log.Debug("Handling request for /status/probe")

	status, err := h.FetchStatusResponse()
	if err != nil {
		return api.Error(PutStatusProbeFailedCode, err)
	}
	return NewPutStatusProbeOK().WithPayload(status)
}
1353909
func (g *Handler) Handle(w http.ResponseWriter, r *http.Request) error {
	log.Info("request for CSR")
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		log.Warningf("failed to read request body: %v", err)
		return errors.NewBadRequest(err)
	}
	r.Body.Close()

	req := new(csr.CertificateRequest)
	req.KeyRequest = csr.NewBasicKeyRequest()
	err = json.Unmarshal(body, req)
	if err != nil {
		log.Warningf("failed to unmarshal request: %v", err)
		return errors.NewBadRequest(err)
	}

	if req.CA != nil {
		log.Warningf("request received with CA section")
		return errors.NewBadRequestString("ca section only permitted in initca")
	}

	csr, key, err := g.generator.ProcessRequest(req)
	if err != nil {
		log.Warningf("failed to process CSR: %v", err)
		// The validator returns a *cfssl/errors.HttpError
		return err
	}

	sum, err := computeSum(csr)
	if err != nil {
		return errors.NewBadRequest(err)
	}

	// Both key and csr are returned PEM-encoded.
	response := api.NewSuccessResponse(&CertRequest{
		Key:  string(key),
		CSR:  string(csr),
		Sums: map[string]Sum{"certificate_request": sum},
	})
	w.Header().Set("Content-Type", "application/json")
	enc := json.NewEncoder(w)
	err = enc.Encode(response)
	return err
}
457846
func (h *Handler) Handle(err error) {
	// Get HTTP request (if any)
	req, _ := httperr.HTTPRequest(err)

	notice := h.notifier.Notice(emperror.ExposeStackTrace(err), req, 1)

	// Extract context from the error and attach it to the notice
	notice.Params = keyvals.ToMap(emperror.Context(err))

	if h.sendSynchronously {
		_, _ = h.notifier.SendNotice(notice)
	} else {
		h.notifier.SendNoticeAsync(notice)
	}
}
360300
func (fn UploadTaskFileHandlerFunc) Handle(params UploadTaskFileParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
356886
func (fn CreateHandlerFunc) Handle(params CreateParams, principal *models.Principal) middleware.Responder {
	return fn(params, principal)
}
240199
func (o *Options) Handler(handler http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		initOnce.Do(func() {
			options = make(map[*http.Request]*Options)
			responded = make(map[*http.Request]bool)
		})
		mutex.Lock()
		options[r] = o
		mutex.Unlock()
		defer func() {
			mutex.Lock()
			delete(options, r)
			delete(responded, r)
			mutex.Unlock()
		}()
		handler.ServeHTTP(w, r)
	})
}
286626
func (p *handler) Handle(event json.RawMessage, ctx *apex.Context) (interface{}, error) {
	proxyEvent := &Event{}

	err := json.Unmarshal(event, proxyEvent)
	if err != nil {
		return nil, fmt.Errorf("Parse proxy event: %s", err)
	}

	req, err := buildRequest(proxyEvent, ctx)
	if err != nil {
		return nil, fmt.Errorf("Build request: %s", err)
	}

	res := &ResponseWriter{}
	p.Handler.ServeHTTP(res, req)
	res.finish()

	return &res.response, nil
}
324053
func (fn PetUploadImageHandlerFunc) Handle(params PetUploadImageParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
1090193
func (h *Handler) Handle(w http.ResponseWriter, r *http.Request) error {
	var newExpiryTime = 7 * helpers.OneDay

	certs, err := h.dbAccessor.GetRevokedAndUnexpiredCertificates()
	if err != nil {
		return err
	}

	queryExpiryTime := r.URL.Query().Get("expiry")
	if queryExpiryTime != "" {
		log.Infof("requested expiry time of %s", queryExpiryTime)
		newExpiryTime, err = time.ParseDuration(queryExpiryTime)
		if err != nil {
			return err
		}
	}

	result, err := crl.NewCRLFromDB(certs, h.ca, h.key, newExpiryTime)
	if err != nil {
		return err
	}

	return api.SendResponse(w, result)
}
425739
func (h HandlerFunc) Handle(event json.RawMessage, ctx *Context) (interface{}, error) {
	return h(event, ctx)
}
632714
func (h *MultiHandler) Handle(w http.ResponseWriter, r *http.Request) error {
	req := new(info.Req)
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		log.Warningf("failed to read request body: %v", err)
		return errors.NewBadRequest(err)
	}
	r.Body.Close()

	err = json.Unmarshal(body, req)
	if err != nil {
		log.Warningf("failed to unmarshal request: %v", err)
		return errors.NewBadRequest(err)
	}

	log.Debug("checking label")
	if req.Label == "" {
		req.Label = h.defaultLabel
	}

	if _, ok := h.signers[req.Label]; !ok {
		log.Warningf("request for invalid endpoint")
		return errors.NewBadRequestString("bad label")
	}

	log.Debug("getting info")
	resp, err := h.signers[req.Label].Info(*req)
	if err != nil {
		log.Infof("error getting certificate: %v", err)
		return err
	}

	response := api.NewSuccessResponse(resp)
	w.Header().Set("Content-Type", "application/json")
	enc := json.NewEncoder(w)
	return enc.Encode(response)
}
182541
func (h *AsyncHttpHandler) handle(f func() (string, error)) {
	go func() {
		logger.Info("Started job %v", h.id)

		ts := time.Now()
		url, err := f()
		logger.Info("Completed job %v in %v", h.id, time.Since(ts))

		if err != nil {
			h.CompletedWithError(err)
		} else if url != "" {
			h.CompletedWithLocation(url)
		} else {
			h.Completed()
		}
	}()
}