diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-23 18:37:37 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-23 18:37:37 +0200 |
commit | 134f7e1cb59b7c1bd4f2eadfebe7f65da1264988 (patch) | |
tree | 0d216c95de64c3f46412a9f87e5dcfe8ad067ea3 /handler.go | |
parent | 9b38f5a034486c27eaf81062ecdd86a72667e2b0 (diff) |
added start on get-anchors code path
Diffstat (limited to 'handler.go')
-rw-r--r-- | handler.go | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -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 |