MCPcopy
hub / github.com/perkeep/perkeep / serveHelpHTML

Method serveHelpHTML

pkg/server/help.go:164–186  ·  view source on GitHub ↗
(cc *clientconfig.Config, rw http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

162}
163
164func (hh *HelpHandler) serveHelpHTML(cc *clientconfig.Config, rw http.ResponseWriter, req *http.Request) {
165 jsonBytes, err := json.MarshalIndent(cc, "", " ")
166 if err != nil {
167 httputil.ServeError(rw, req, fmt.Errorf("could not serialize client config JSON: %v", err))
168 return
169 }
170
171 var hint template.HTML
172 if strings.HasPrefix(hh.serverSecRing, "/gcs/") {
173 bucketdir := strings.TrimPrefix(hh.serverSecRing, "/gcs/")
174 bucketdir = strings.TrimSuffix(bucketdir, "/identity-secring.gpg")
175 hint = template.HTML(fmt.Sprintf("<p>Download your GnuPG secret ring from <a href=\"https://console.developers.google.com/storage/browser/%s/\">https://console.developers.google.com/storage/browser/%s/</a> and place it in your <a href='https://perkeep.org/doc/client-config'>Perkeep client config directory</a>. Keep it private. It's not encrypted or password-protected and anybody in possession of it can create Perkeep claims as your identity.</p>\n",
176 bucketdir, bucketdir))
177 }
178
179 hh.goTemplate.Execute(rw, struct {
180 ClientConfigJSON string
181 SecringDownloadHint template.HTML
182 }{
183 ClientConfigJSON: string(jsonBytes),
184 SecringDownloadHint: hint,
185 })
186}

Callers 1

ServeHTTPMethod · 0.95

Calls 2

ServeErrorFunction · 0.92
HasPrefixMethod · 0.80

Tested by

no test coverage detected