| 844 | ) |
| 845 | |
| 846 | func (h configHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { |
| 847 | w.Header().Set("Content-Type", "text/plain; charset=utf-8") |
| 848 | b, _ := json.MarshalIndent(h.c.jconf, "", " ") |
| 849 | b = knownKeys.ReplaceAll(b, nil) |
| 850 | b = trailingComma.ReplaceAll(b, []byte("$1")) |
| 851 | b = sensitiveLine.ReplaceAllFunc(b, func(ln []byte) []byte { |
| 852 | i := bytes.IndexByte(ln, ':') |
| 853 | r := string(ln[:i+1]) + ` "REDACTED"` |
| 854 | if bytes.HasSuffix(bytes.TrimSpace(ln), []byte{','}) { |
| 855 | r += "," |
| 856 | } |
| 857 | return []byte(r + "\n") |
| 858 | }) |
| 859 | w.Write(b) |
| 860 | } |
| 861 | |
| 862 | // profileHandler publishes server profile information. |
| 863 | type profileHandler struct{} |