// newCallBackHandler creates a oneway handler that fills a channel
// with the received body
975864
func newCallBackHandler() (raw.OnewayHandler, <-chan map[string]string) {
	serverCalledBack := make(chan map[string]string)
	return func(ctx context.Context, body []byte) error {
		serverCalledBack <- extractBaggage(ctx)
		return nil
	}, serverCalledBack
}
1050129
func (t *Trace) NewHandler(next http.Handler) (http.Handler, error) {
	return newTraceHandler(next, t)
}
588147
func wrapOnewayHandler(name string, handler interface{}) transport.OnewayHandler {
	reqBodyType := verifyOnewaySignature(name, reflect.TypeOf(handler))
	return newJSONHandler(reqBodyType, handler)
}
970541
func NewHandler(n *centrifuge.Node, c Config) *Handler {
	h := &Handler{
		node:   n,
		config: c,
	}
	return h
}
47536
func NewHandler(s Sender, tags []string) func(xhandler.HandlerC) xhandler.HandlerC {
	return NewHandlerPrefix(s, tags, "")
}
92857
func NewHandler(c Config) func(http.Handler) http.Handler {
	if c.Output == nil {
		c.Output = NewOutputChannel(NewConsoleOutput())
	}
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			var l Logger
			if r != nil {
				l = New(c)
				r = r.WithContext(NewContext(r.Context(), l))
			}
			next.ServeHTTP(w, r)
			if l, ok := l.(*logger); ok {
				l.close()
			}
		})
	}
}
481785
func NewHandler(params *HandlerParams) *Handler {
	fh := &Handler{
		cache: make(map[uint64]*cacheEntry),
	}

	for i := 0; i < hasherCount; i++ {
		hashfunc := storage.MakeHashFunc(feedsHashAlgorithm)()
		if fh.HashSize == 0 {
			fh.HashSize = hashfunc.Size()
		}
		hashPool.Put(hashfunc)
	}

	return fh
}
1123160
func (d *Dispatcher) NewHandlerFunc() HandlerFunc {
	if len(d.serviceMap) == 0 {
		logPanic("gorpc.Dispatcher: register at least one service before calling HandlerFunc()")
	}

	serviceMap := copyServiceMap(d.serviceMap)

	return func(clientAddr string, request interface{}) interface{} {
		req, ok := request.(*dispatcherRequest)
		if !ok {
			logPanic("gorpc.Dispatcher: unsupported request type received from the client: %T", request)
		}
		return dispatchRequest(serviceMap, clientAddr, req)
	}
}
874876
func (m *callback) HandleCallback(s connector.Scopes, r *http.Request) (connector.Identity, error) {
	remoteUser := r.Header.Get("X-Remote-User")
	if remoteUser == "" {
		return connector.Identity{}, fmt.Errorf("required HTTP header X-Remote-User is not set")
	}
	// TODO: add support for X-Remote-Group, see
	// https://kubernetes.io/docs/admin/authentication/#authenticating-proxy
	return connector.Identity{
		UserID:        remoteUser, // TODO: figure out if this is a bad ID value.
		Email:         remoteUser,
		EmailVerified: true,
	}, nil
}
59053
func newHTTPHandler(f func(c context.Context) error) router.Handler {
	return func(c *router.Context) {
		c.Writer.Header().Set("Content-Type", "text/plain")

		if err := f(c.Context); err != nil {
			errors.Log(c.Context, err)
			c.Writer.WriteHeader(http.StatusInternalServerError)
			return
		}

		c.Writer.WriteHeader(http.StatusOK)
	}
}
324926
func NewHandler() *Handler {
	h := &Handler{
		router: httprouter.New(),
		Logger: log15.New(),
	}
	h.router.POST("/clusters", h.servePostCluster)
	h.router.DELETE("/clusters", h.serveDeleteCluster)
	h.router.GET("/ping", h.serveGetPing)
	return h
}
1272777
func NewEventHandler() *EventHandler {
	h := EventHandler{
		inbox:      make(chan eh.Event, 1),
		register:   make(chan *EventListener),
		unregister: make(chan *EventListener),
	}
	go h.run()
	return &h
}
912315
func NewReaderCallback(onRead CountCallback, reader io.Reader) *Reader {
	return &Reader{
		reader: reader,
		onRead: onRead,
	}
}
510743
func (p *Provider) handleCallback(rw http.ResponseWriter, req *http.Request, _ router.Params) error {
	// oauth handshake
	code := req.FormValue("code")
	accessToken, err := p.Config.Exchange(oauth2.NoContext, code)
	if err != nil {
		return errors.Wrap(err)
	}
	var state string
	encState := req.FormValue("state")
	if encState != "" {
		stateByte, err := base64.StdEncoding.DecodeString(encState)
		if err != nil {
			return errors.New("error decoding state: %s", err)
		}
		state = string(stateByte)
	}
	err = p.PostCallback(req, rw, accessToken, state)
	if err != nil {
		return errors.Wrap(err)
	}
	return nil
}
1309519
func NewHandler(h http.Handler) http.Handler {
	return NewHandlerWith(stats.DefaultEngine, h)
}
1009931
func NewHandler(event string, fn interface{}) (ThrustEventHandler, error) {
	h := ThrustEventHandler{}
	h.Event = event
	h.Type = "event"
	err := h.SetHandleFunc(fn)
	dispatcher.RegisterHandler(h)
	return h, err
}
285884
func NewHandler(
	e endpoint.Endpoint,
	dec DecodeRequestFunc,
	enc EncodeResponseFunc,
	options ...HandlerOption,
) *Handler {
	h := &Handler{
		e:            e,
		dec:          dec,
		enc:          enc,
		errorEncoder: DefaultErrorEncoder,
		errorHandler: transport.NewLogErrorHandler(log.NewNopLogger()),
	}
	for _, option := range options {
		option(h)
	}
	return h
}