Debian Codegraph @

internal/web/examplecert.go

raw symbols SCIP
1 package web
2
3 import (
4 "net/http"
5
6 "github.com/d-Rickyy-b/certstream-server-go/internal/models"
7 )
8
9 var exampleCert models.Entry
10
11 // exampleFull handles requests to the /full-stream/example.json endpoint.
12 // It returns a JSON representation of the full example certificate.
13 func exampleFull(w http.ResponseWriter, _ *http.Request) {
14 w.Header().Set("Content-Type", "application/json")
15 w.Write(exampleCert.JSON()) //nolint:errcheck
16 }
17
18 // exampleLite handles requests to the /example.json endpoint.
19 // It returns a JSON representation of the lite example certificate.
20 func exampleLite(w http.ResponseWriter, _ *http.Request) {
21 w.Header().Set("Content-Type", "application/json")
22 w.Write(exampleCert.JSONLite()) //nolint:errcheck
23 }
24
25 // exampleDomains handles requests to the /domains-only/example.json endpoint.
26 // It returns a JSON representation of the domain data.
27 func exampleDomains(w http.ResponseWriter, _ *http.Request) {
28 w.Header().Set("Content-Type", "application/json")
29 w.Write(exampleCert.JSONDomains()) //nolint:errcheck
30 }
31
32 // SetExampleCert sets one certificate as the example Cert that is returned by the example endpoints.
33 func SetExampleCert(cert models.Entry) {
34 exampleCert = cert
35 }