MCPcopy Index your code
hub / github.com/cortexproject/cortex / indexHandler

Function indexHandler

pkg/api/handlers.go:101–116  ·  view source on GitHub ↗
(httpPathPrefix string, content *IndexPageContent)

Source from the content-addressed store, hash-verified

99</html>`
100
101func indexHandler(httpPathPrefix string, content *IndexPageContent) http.HandlerFunc {
102 templ := template.New("main")
103 templ.Funcs(map[string]any{
104 "AddPathPrefix": func(link string) string {
105 return path.Join(httpPathPrefix, link)
106 },
107 })
108 template.Must(templ.Parse(indexPageTemplate))
109
110 return func(w http.ResponseWriter, r *http.Request) {
111 err := templ.Execute(w, content.GetContent())
112 if err != nil {
113 http.Error(w, err.Error(), http.StatusInternalServerError)
114 }
115 }
116}
117
118func (cfg *Config) configHandler(actualCfg any, defaultCfg any) http.HandlerFunc {
119 if cfg.CustomConfigHandler != nil {

Callers 3

RegisterAPIMethod · 0.85
TestIndexHandlerPrefixFunction · 0.85
TestIndexPageContentFunction · 0.85

Calls 4

JoinMethod · 0.80
ParseMethod · 0.80
GetContentMethod · 0.80
ErrorMethod · 0.45

Tested by 2

TestIndexHandlerPrefixFunction · 0.68
TestIndexPageContentFunction · 0.68