aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
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