fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

indexserver: add endpoint /debug/host (#501)

We serve the hostname so that we can associate a repo with its
indexserver on the repo status page in Sourcegraph.

+27
+27
cmd/zoekt-sourcegraph-indexserver/main.go
··· 191 191 // repositoriesSkipSymbolsCalculationAllowList is an allowlist for repositories that 192 192 // we skip calculating symbols metadata for during builds 193 193 repositoriesSkipSymbolsCalculationAllowList map[string]struct{} 194 + 195 + hostname string 194 196 } 195 197 196 198 var debug = log.New(io.Discard, "", log.LstdFlags) ··· 654 656 mux.Handle("/debug/list", http.HandlerFunc(s.handleDebugList)) 655 657 mux.Handle("/debug/merge", http.HandlerFunc(s.handleDebugMerge)) 656 658 mux.Handle("/debug/queue", http.HandlerFunc(s.queue.handleDebugQueue)) 659 + mux.Handle("/debug/host", http.HandlerFunc(s.handleHost)) 657 660 } 658 661 659 662 var repoTmpl = template.Must(template.New("name").Parse(` ··· 670 673 </form> 671 674 </body></html> 672 675 `)) 676 + 677 + func (s *Server) handleHost(w http.ResponseWriter, r *http.Request) { 678 + if r.Method != "GET" { 679 + w.Header().Set("Allow", "GET") 680 + w.WriteHeader(http.StatusMethodNotAllowed) 681 + return 682 + } 683 + 684 + response := struct { 685 + Hostname string 686 + }{ 687 + Hostname: s.hostname, 688 + } 689 + 690 + b, err := json.Marshal(response) 691 + if err != nil { 692 + http.Error(w, err.Error(), http.StatusInternalServerError) 693 + return 694 + } 695 + 696 + w.Header().Set("Content-Type", "application/json; charset=utf-8") 697 + w.Write(b) 698 + } 673 699 674 700 func (s *Server) handleRoot(w http.ResponseWriter, r *http.Request) { 675 701 renderRoot := func(indexMsg string) { ··· 1334 1360 deltaBuildRepositoriesAllowList: deltaBuildRepositoriesAllowList, 1335 1361 deltaShardNumberFallbackThreshold: deltaShardNumberFallbackThreshold, 1336 1362 repositoriesSkipSymbolsCalculationAllowList: reposShouldSkipSymbolsCalculation, 1363 + hostname: conf.hostname, 1337 1364 }, err 1338 1365 } 1339 1366