github.com/grafana/pyroscope@v1.18.0/pkg/api/memberlist_status.go (about)

     1  // SPDX-License-Identifier: AGPL-3.0-only
     2  // Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/api/handlers.go
     3  // Provenance-includes-license: Apache-2.0
     4  // Provenance-includes-copyright: The Cortex Authors.
     5  
     6  package api
     7  
     8  import (
     9  	_ "embed"
    10  	"html/template"
    11  	"net/http"
    12  	"path"
    13  	"strings"
    14  
    15  	"github.com/grafana/dskit/kv/memberlist"
    16  )
    17  
    18  //go:embed memberlist_status.gohtml
    19  var memberlistStatusPageHTML string
    20  
    21  func MemberlistStatusHandler(httpPathPrefix string, kvs *memberlist.KVInitService) http.Handler {
    22  	templ := template.New("memberlist_status")
    23  	templ.Funcs(map[string]interface{}{
    24  		"AddPathPrefix": func(link string) string { return path.Join(httpPathPrefix, link) },
    25  		"StringsJoin":   strings.Join,
    26  	})
    27  	template.Must(templ.Parse(memberlistStatusPageHTML))
    28  	return memberlist.NewHTTPStatusHandler(kvs, templ)
    29  }