// NewLabelHandler returns a new instance of LabelHandler
420629
func NewLabelHandler(s influxdb.LabelService) *LabelHandler {
	h := &LabelHandler{
		Router:       NewRouter(),
		Logger:       zap.NewNop(),
		LabelService: s,
	}

	h.HandlerFunc("POST", labelsPath, h.handlePostLabel)
	h.HandlerFunc("GET", labelsPath, h.handleGetLabels)

	h.HandlerFunc("GET", labelsIDPath, h.handleGetLabel)
	h.HandlerFunc("PATCH", labelsIDPath, h.handlePatchLabel)
	h.HandlerFunc("DELETE", labelsIDPath, h.handleDeleteLabel)

	return h
}
578276
func NewHostPrefixHandler(prefix string, labelsFn func() map[string]string) request.NamedHandler {
	builder := HostPrefixBuilder{
		Prefix:   prefix,
		LabelsFn: labelsFn,
	}

	return request.NamedHandler{
		Name: HostPrefixHandlerName,
		Fn:   builder.Build,
	}
}
164368
func NewMultiHandler(signers map[string]signer.Signer, defaultLabel string) (http.Handler, error) {
	return &api.HTTPHandler{
		Handler: &MultiHandler{
			signers:      signers,
			defaultLabel: defaultLabel,
		},
		Methods: []string{"POST"},
	}, nil
}
780676
func CreateLabel(lbl string, x, y, w, h int, fg, bg termbox.Attribute) *Label {
	c := Label{
		value: lbl, x: x, y: y, width: w, height: h,
		fg: fg, bg: bg, activeFg: fg, activeBg: bg,
	}
	return &c
}
850793
func (c *ConnLimit) NewHandler(next http.Handler) (http.Handler, error) {
	extract, err := utils.NewExtractor(c.Variable)
	if err != nil {
		return nil, err
	}
	return connlimit.New(next, extract, c.Connections)
}
289978
func NewHandler(s Sender, tags []string) func(http.Handler) http.Handler {
	return NewHandlerPrefix(s, tags, "")
}
941263
func NewEventHandler(eventHandler eh.EventHandler) *EventHandler {
	h := &EventHandler{
		EventHandler: eventHandler,
		eventsCh:     make(chan data),
		errCh:        make(chan error, 1),
	}

	go h.run()

	return h
}
727234
func NewDocumentHandler(b *DocumentBackend) *DocumentHandler {
	h := &DocumentHandler{
		Router: NewRouter(),
		Logger: b.Logger,

		DocumentService: b.DocumentService,
		LabelService:    b.LabelService,
	}

	h.HandlerFunc("POST", documentsPath, h.handlePostDocument)
	h.HandlerFunc("GET", documentsPath, h.handleGetDocuments)
	h.HandlerFunc("GET", documentPath, h.handleGetDocument)
	h.HandlerFunc("PUT", documentPath, h.handlePutDocument)
	h.HandlerFunc("DELETE", documentPath, h.handleDeleteDocument)

	h.HandlerFunc("GET", documentLabelsPath, h.handleGetDocumentLabel)
	h.HandlerFunc("POST", documentLabelsPath, h.handlePostDocumentLabel)
	h.HandlerFunc("DELETE", documentLabelsIDPath, h.handleDeleteDocumentLabel)

	return h
}
248694
func NewHandler(StartingContext context.Context, Ending ContextHandler) *Handler {
	h := &Handler{
		Ending:          Ending,
		Chain:           []Constructor{},
		StartingContext: StartingContext,
	}
	h.Pool.New = func() interface{} {
		return h.newStack()
	}
	return h
}
730552
func NewFieldHandler(next http.Handler, name string, value string, applyFn FieldApply) http.Handler {
	return &FieldHandler{next: next, name: name, value: value, applyFn: applyFn}
}
516647
func (s *LabelService) CreateLabelMapping(ctx context.Context, m *platform.LabelMapping) error {
	return s.CreateLabelMappingFn(ctx, m)
}
770439
func NewVariableHandler(b *VariableBackend) *VariableHandler {
	h := &VariableHandler{
		Router: NewRouter(),
		Logger: b.Logger,

		VariableService: b.VariableService,
		LabelService:    b.LabelService,
	}

	entityPath := fmt.Sprintf("%s/:id", variablePath)
	entityLabelsPath := fmt.Sprintf("%s/labels", entityPath)
	entityLabelsIDPath := fmt.Sprintf("%s/:lid", entityLabelsPath)

	h.HandlerFunc("GET", variablePath, h.handleGetVariables)
	h.HandlerFunc("POST", variablePath, h.handlePostVariable)
	h.HandlerFunc("GET", entityPath, h.handleGetVariable)
	h.HandlerFunc("PATCH", entityPath, h.handlePatchVariable)
	h.HandlerFunc("PUT", entityPath, h.handlePutVariable)
	h.HandlerFunc("DELETE", entityPath, h.handleDeleteVariable)

	labelBackend := &LabelBackend{
		Logger:       b.Logger.With(zap.String("handler", "label")),
		LabelService: b.LabelService,
		ResourceType: platform.DashboardsResourceType,
	}
	h.HandlerFunc("GET", entityLabelsPath, newGetLabelsHandler(labelBackend))
	h.HandlerFunc("POST", entityLabelsPath, newPostLabelHandler(labelBackend))
	h.HandlerFunc("DELETE", entityLabelsIDPath, newDeleteLabelHandler(labelBackend))

	return h
}
910268
func NewHandler(expiration time.Duration) *Handler {
	return &Handler{
		rule:       DefaultRuleSet,
		expiration: expiration,
		entries:    make(map[string]*entry.Entry, 0),
	}
}
1054927
func NewHandler(manifest string) Handler {
	mux := http.NewServeMux()

	mux.HandleFunc(activatePath, func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", DefaultContentTypeV1_1)
		fmt.Fprintln(w, manifest)
	})

	return Handler{mux: mux}
}
1113592
func NewHandler(conn io.ReadWriteCloser) Handler {
	rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
	return Handler{
		rw:   rw,
		conn: conn,
	}
}
1214405
func NewHandler() *Handler {
	h := &Handler{
		router: httprouter.New(),
		Logger: log15.New(),
	}
	h.router.Handler("GET", status.Path, status.Handler(h.healthStatus))
	h.router.GET("/status", h.handleGetStatus)
	h.router.GET("/backup", h.handleGetBackup)
	h.router.POST("/stop", h.handlePostStop)
	return h
}
772863
func newPatchLabelHandler(s plat.LabelService) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()

		req, err := decodePatchLabelRequest(ctx, r)
		if err != nil {
			EncodeError(ctx, err, w)
			return
		}

		label, err := s.UpdateLabel(ctx, req.label, req.upd)
		if err != nil {
			EncodeError(ctx, err, w)
			return
		}

		if err := encodeResponse(ctx, w, http.StatusOK, newLabelResponse(label)); err != nil {
			// TODO: this can potentially result in calling w.WriteHeader multiple times, we need to pass a logger in here
			// some how. This isn't as simple as simply passing in a logger to this function since the time that this function
			// is called is distinct from the time that a potential logger is set.
			EncodeError(ctx, err, w)
			return
		}
	}
}