// Handle triggers the collect-metrics hook and writes collected metrics
// to the specified connection.
11176
func (l *handler) Handle(c net.Conn, abort <-chan struct{}) error {
	defer c.Close()

	// TODO(fwereade): 2016-03-17 lp:1558657
	err := c.SetDeadline(time.Now().Add(spool.DefaultTimeout))
	if err != nil {
		return errors.Annotate(err, "failed to set the deadline")
	}

	err = l.config.charmdir.Visit(func() error {
		return l.do(c)
	}, abort)
	if err != nil {
		fmt.Fprintf(c, "error: %v\n", err.Error())
	} else {
		fmt.Fprintf(c, "ok\n")
	}
	return errors.Trace(err)
}
939948
func (eh relationshipAddEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*RelationshipAdd); ok {
		eh(s, t)
	}
}
37938
func (eh guildBanRemoveEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*GuildBanRemove); ok {
		eh(s, t)
	}
}
717515
func (eh guildRoleCreateEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*GuildRoleCreate); ok {
		eh(s, t)
	}
}
995740
func (h *Handler) 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)
	}

	resp, err := h.sign.Info(*req)
	if err != nil {
		return err
	}

	response := api.NewSuccessResponse(resp)
	w.Header().Set("Content-Type", "application/json")
	enc := json.NewEncoder(w)
	return enc.Encode(response)
}
784396
func (h *compositeHandler) Handle(err error) {
	for _, handler := range h.handlers {
		handler.Handle(err)
	}
}
405671
func (h ServiceGeneratorHandler) Handle(name string, reqValue wire.Value) (wire.Value, error) {
	switch name {

	case "generate":

		var args ServiceGenerator_Generate_Args
		if err := args.FromWire(reqValue); err != nil {
			return wire.Value{}, err
		}

		result, err := ServiceGenerator_Generate_Helper.WrapResponse(
			h.impl.Generate(args.Request),
		)
		if err != nil {
			return wire.Value{}, err
		}

		return result.ToWire()

	default:

		return wire.Value{}, envelope.ErrUnknownMethod(name)

	}
}
125762
func (fn PetUpdateHandlerFunc) Handle(params PetUpdateParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
98321
func (s *Server) Handle(method string, h http.Handler) {
	s.muHandlers.Lock()
	defer s.muHandlers.Unlock()
	s.handlers[method] = h
}
248818
func (f HandlerFunc) Handle(w http.ResponseWriter, r *http.Request) error {
	w.Header().Set("Content-Type", "application/json")
	return f(w, r)
}
179414
func (fn PetGetHandlerFunc) Handle(params PetGetParams, principal interface{}) middleware.Responder {
	return fn(params, principal)
}
889653
func (w *Handler) Handle(key string, h func(eventtypes.Message)) {
	w.mu.Lock()
	w.handlers[key] = h
	w.mu.Unlock()
}
405123
func (r *Reader) handle(ws *websocket.Conn) {
	// Close the connection when the client requests it, or when we finish streaming, whichever happens first
	closeConnOnce := &sync.Once{}
	closeConn := func() {
		closeConnOnce.Do(func() {
			ws.Close()
		})
	}

	negotiated := ws.Config().Protocol
	r.selectedProtocol = negotiated[0]
	defer close(r.err)
	defer closeConn()

	go func() {
		defer runtime.HandleCrash()
		// This blocks until the connection is closed.
		// Client should not send anything.
		IgnoreReceives(ws, r.timeout)
		// Once the client closes, we should also close
		closeConn()
	}()

	r.err <- messageCopy(ws, r.r, !r.protocols[r.selectedProtocol].Binary, r.ping, r.timeout)
}
1105643
func (c *UsergroupsCreateCall) Handle(handle string) *UsergroupsCreateCall {
	c.handle = handle
	return c
}
15537
func (h HandlerFunc) Handle(data json.RawMessage, ctx *apex.Context) (interface{}, error) {
	event, record := new(Event), new(Record)

	if err := json.Unmarshal(data, record); err != nil {
		return nil, err
	}

	if err := decode(record, event); err != nil {
		return nil, err
	}

	if err := h(event, ctx); err != nil {
		return nil, err
	}

	return event, nil
}
1123647
func (b *SinkHandler) Handle(rec *Record) {
	select {
	case b.sinkCh <- rec:
	default:
		fmt.Fprintf(os.Stderr, "SinkHandler buffer too small dropping record\n")
	}
}
898184
func (eh relationshipRemoveEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*RelationshipRemove); ok {
		eh(s, t)
	}
}