aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-23 18:37:37 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-23 18:37:37 +0200
commit134f7e1cb59b7c1bd4f2eadfebe7f65da1264988 (patch)
tree0d216c95de64c3f46412a9f87e5dcfe8ad067ea3 /handler.go
parent9b38f5a034486c27eaf81062ecdd86a72667e2b0 (diff)
added start on get-anchors code path
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/handler.go b/handler.go
index 27b2fd9..42f9e23 100644
--- a/handler.go
+++ b/handler.go
@@ -120,9 +120,20 @@ func getEntries(ctx context.Context, i *instance, w http.ResponseWriter, r *http
}
// getAnchors provides a list of configured trust anchors
-func getAnchors(ctx context.Context, i *instance, w http.ResponseWriter, r *http.Request) (int, error) {
+func getAnchors(_ context.Context, i *instance, w http.ResponseWriter, _ *http.Request) (int, error) {
glog.Info("in getAnchors")
- return http.StatusOK, nil // TODO
+ data := NewGetAnchorsResponse(i.anchorsPool.RawCertificates())
+ json, err := json.Marshal(&data)
+ if err != nil {
+ return http.StatusInternalServerError, fmt.Errorf("failed json-encoding GetAnchorsResponse: %v", err)
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ _, err = w.Write(json)
+ if err != nil {
+ return http.StatusInternalServerError, fmt.Errorf("failed writing get-anchors response: %v", err)
+ }
+ return http.StatusOK, nil
}
// getProofByHash provides an inclusion proof based on a given leaf hash