diff options
author | Linus Nordberg <linus@nordberg.se> | 2022-05-24 23:33:38 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@mullvad.net> | 2022-06-23 11:33:17 +0200 |
commit | 559bccccd40d028e412d9f11709ded0250ba6dcd (patch) | |
tree | 50f3193dbe70fec21357963c11e5f663013f4b4c /internal/node/primary/endpoint_internal.go | |
parent | 4b20ef0c1732bcef633c0ed7104501898aa84e2c (diff) |
implement primary and secondary role, for replicationv0.5.0
Diffstat (limited to 'internal/node/primary/endpoint_internal.go')
-rw-r--r-- | internal/node/primary/endpoint_internal.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/node/primary/endpoint_internal.go b/internal/node/primary/endpoint_internal.go new file mode 100644 index 0000000..f7a684f --- /dev/null +++ b/internal/node/primary/endpoint_internal.go @@ -0,0 +1,30 @@ +package primary + +// This file implements internal HTTP handler callbacks for primary nodes. + +import ( + "context" + "fmt" + "net/http" + + "git.sigsum.org/log-go/internal/node/handler" + "git.sigsum.org/sigsum-go/pkg/log" + "git.sigsum.org/sigsum-go/pkg/types" +) + +func getTreeHeadUnsigned(ctx context.Context, c handler.Config, w http.ResponseWriter, _ *http.Request) (int, error) { + log.Debug("handling %s request", types.EndpointGetTreeHeadUnsigned) + p := c.(Primary) + th, err := p.TrillianClient.GetTreeHead(ctx) + if err != nil { + return http.StatusInternalServerError, fmt.Errorf("failed getting tree head: %v", err) + } + if err := th.ToASCII(w); err != nil { + return http.StatusInternalServerError, err + } + return http.StatusOK, nil +} + +func getLeavesInternal(ctx context.Context, c handler.Config, w http.ResponseWriter, r *http.Request) (int, error) { + return getLeavesGeneral(ctx, c, w, r, false) +} |