// EncodeHandle encodes handle in data.
499196
func EncodeHandle(h int64) []byte {
	buf := &bytes.Buffer{}
	err := binary.Write(buf, binary.BigEndian, h)
	if err != nil {
		panic(err)
	}
	return buf.Bytes()
}
962965
func WrapHandler(h *webdav.Handler, confs ...func(c *Config)) gin.HandlerFunc {
	defaultConfig := &Config{
		URL: "doc.json",
	}

	for _, c := range confs {
		c(defaultConfig)
	}

	return CustomWrapHandler(defaultConfig, h)
}
889653
func (w *Handler) Handle(key string, h func(eventtypes.Message)) {
	w.mu.Lock()
	w.handlers[key] = h
	w.mu.Unlock()
}
1312245
func (c *Client) UseHandler(phase string, fn context.HandlerFunc) *Client {
	c.Middleware.UseHandler(phase, fn)
	return c
}
1118827
func (h *Handler) Handle(err error) {
	// Expose the stackTracer interface on the outer error (if there is stack trace in the error)
	// Convert error with stack trace to an internal error type
	if e, ok := emperror.ExposeStackTrace(err).(stackTracer); ok {
		err = newErrorWithStackFrames(e)
	}

	var rawData []interface{}

	if cause := errors.Cause(err); cause != nil {
		if name := reflect.TypeOf(cause).String(); len(name) > 0 {
			errorClass := bugsnag.ErrorClass{Name: name}

			rawData = append(rawData, errorClass)
		}
	}

	if ctx := emperror.Context(err); len(ctx) > 0 {
		rawData = append(rawData, bugsnag.MetaData{
			"Params": keyvals.ToMap(ctx),
		})
	}

	_ = h.notifier.Notify(err, rawData...)
}
382715
func (k *Kite) addHandle(method string, handler Handler) *Method {
	authenticate := true
	if k.Config.DisableAuthentication {
		authenticate = false
	}

	m := &Method{
		name:         method,
		handler:      handler,
		authenticate: authenticate,
		handling:     k.MethodHandling,
	}

	k.handlers[method] = m
	return m
}
710797
func (m *Mux) UseHandler(phase string, fn c.HandlerFunc) *Mux {
	m.Middleware.UseHandler(phase, fn)
	return m
}
1209735
func (t *Tango) UseHandler(handler http.Handler) {
	t.Use(WrapBefore(handler))
}
573941
func (app *App) UseHandler(h Handler) *App {
	app.mds = append(app.mds, h.Serve)
	return app
}
52389
func (e Encoder) encode(iVal interface{}) error {

	var err error
	switch val := iVal.(type) {
	case nil:
		err = e.encodeNil()
	case bool:
		err = e.encodeBool(val)
	case int:
		err = e.encodeInt(int64(val))
	case int8:
		err = e.encodeInt(int64(val))
	case int16:
		err = e.encodeInt(int64(val))
	case int32:
		err = e.encodeInt(int64(val))
	case int64:
		err = e.encodeInt(val)
	case uint:
		err = e.encodeInt(int64(val))
	case uint8:
		err = e.encodeInt(int64(val))
	case uint16:
		err = e.encodeInt(int64(val))
	case uint32:
		err = e.encodeInt(int64(val))
	case uint64:
		if val > math.MaxInt64 {
			return errors.New("Integer too big: %d. Max integer supported: %d", val, int64(math.MaxInt64))
		}
		err = e.encodeInt(int64(val))
	case float32:
		err = e.encodeFloat(float64(val))
	case float64:
		err = e.encodeFloat(val)
	case string:
		err = e.encodeString(val)
	case []interface{}:
		err = e.encodeSlice(val)
	case map[string]interface{}:
		err = e.encodeMap(val)
	case structures.Structure:
		err = e.encodeStructure(val)
	default:
		// arbitrary slice types
		if reflect.TypeOf(iVal).Kind() == reflect.Slice {
			s := reflect.ValueOf(iVal)
			newSlice := make([]interface{}, s.Len())
			for i := 0; i < s.Len(); i++ {
				newSlice[i] = s.Index(i).Interface()
			}
			return e.encodeSlice(newSlice)
		}

		return errors.New("Unrecognized type when encoding data for Bolt transport: %T %+v", val, val)
	}

	return err
}
1216754
func (h *Handler) HandleLog(e *log.Entry) error {
	h.mu.Lock()
	defer h.mu.Unlock()
	return h.Encoder.Encode(e)
}
822501
func WrapHandler(h interface{}) Handler {
	if v, ok := h.(HandlerFunc); ok {
		return v
	}
	if v, ok := h.(Handler); ok {
		return v
	}
	if v, ok := h.(func(Context) error); ok {
		return HandlerFunc(v)
	}
	if v, ok := h.(http.Handler); ok {
		return HandlerFunc(func(ctx Context) error {
			v.ServeHTTP(ctx.Response().StdResponseWriter(), ctx.Request().StdRequest())
			return nil
		})
	}
	if v, ok := h.(func(http.ResponseWriter, *http.Request)); ok {
		return HandlerFunc(func(ctx Context) error {
			v(ctx.Response().StdResponseWriter(), ctx.Request().StdRequest())
			return nil
		})
	}
	if v, ok := h.(func(http.ResponseWriter, *http.Request) error); ok {
		return HandlerFunc(func(ctx Context) error {
			return v(ctx.Response().StdResponseWriter(), ctx.Request().StdRequest())
		})
	}
	panic(`unknown handler`)
}
64999
func (s *Server) Handle(typ string, f protocolHandler) {
	s.handlers[typ] = f
}
267740
func (h *Handler) Handle(err error) {
	// Get the context from the error
	ctx := keyvals.ToMap(emperror.Context(err))

	// Expose the stackTracer interface on the outer error (if there is stack trace in the error)
	// Convert error with stack trace to an internal error type
	if e, ok := emperror.ExposeStackTrace(err).(stackTracer); ok {
		err = newCauseStacker(e)
	}

	if req, ok := httperr.HTTPRequest(err); ok {
		h.client.RequestErrorWithStackSkipWithExtras(rollbar.ERR, req, err, 3, ctx)

		return
	}

	h.client.ErrorWithStackSkipWithExtras(rollbar.ERR, err, 3, ctx)
}
1164936
func (service *Service) EncodeResponse(ctx context.Context, v interface{}) error {
	accept := ContextRequest(ctx).Header.Get("Accept")
	return service.Encoder.Encode(v, ContextResponse(ctx), accept)
}
1289304
func MainHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	// For now it only supports `GET`
	if r.Method != "GET" {
		return errors.ErrGenericNotFound.WithDetail(nil)
	}

	if _, err := w.Write([]byte("{}")); err != nil {
		return errors.ErrUnknown.WithDetail(err)
	}
	return nil
}
1278528
func NewHandle(store kv.Storage) *Handle {
	h := &Handle{
		store: store,
	}
	return h
}