aboutsummaryrefslogtreecommitdiff
path: root/pkg/instance/endpoint.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2021-12-20 19:53:54 +0100
committerRasmus Dahlberg <rasmus@mullvad.net>2021-12-20 19:53:54 +0100
commitdda238b9fc105219f220f0ec3b341b0c81b71301 (patch)
treeedbbb787ccd1c1816edfa44caf749c8be68b7bf9 /pkg/instance/endpoint.go
parent5ba4a77233549819440cc41a02503f3a85213e24 (diff)
types: Start using sigsum-lib-go
This commit does not change the way in which the log behaves externally. In other words, all changes are internal and involves renaming and code restructuring. Most notably picking up the refactored sigsum-lib-go.
Diffstat (limited to 'pkg/instance/endpoint.go')
-rw-r--r--pkg/instance/endpoint.go122
1 files changed, 0 insertions, 122 deletions
diff --git a/pkg/instance/endpoint.go b/pkg/instance/endpoint.go
deleted file mode 100644
index a6d424d..0000000
--- a/pkg/instance/endpoint.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package instance
-
-import (
- "context"
- "net/http"
-
- "github.com/golang/glog"
-)
-
-func addLeaf(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) {
- glog.V(3).Info("handling add-entry request")
- req, err := i.leafRequestFromHTTP(ctx, r)
- if err != nil {
- return http.StatusBadRequest, err
- }
- if err := i.Client.AddLeaf(ctx, req); err != nil {
- return http.StatusInternalServerError, err
- }
- return http.StatusOK, nil
-}
-
-func addCosignature(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) {
- glog.V(3).Info("handling add-cosignature request")
- req, err := i.cosignatureRequestFromHTTP(r)
- if err != nil {
- return http.StatusBadRequest, err
- }
- vk := i.Witnesses[*req.KeyHash]
- if err := i.Stateman.AddCosignature(ctx, &vk, req.Signature); err != nil {
- return http.StatusBadRequest, err
- }
- return http.StatusOK, nil
-}
-
-func getTreeHeadLatest(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Request) (int, error) {
- glog.V(3).Info("handling get-tree-head-latest request")
- sth, err := i.Stateman.Latest(ctx)
- if err != nil {
- return http.StatusInternalServerError, err
- }
- if err := sth.MarshalASCII(w); err != nil {
- return http.StatusInternalServerError, err
- }
- return http.StatusOK, nil
-}
-
-func getTreeHeadToSign(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Request) (int, error) {
- glog.V(3).Info("handling get-tree-head-to-sign request")
- sth, err := i.Stateman.ToSign(ctx)
- if err != nil {
- return http.StatusInternalServerError, err
- }
- if err := sth.MarshalASCII(w); err != nil {
- return http.StatusInternalServerError, err
- }
- return http.StatusOK, nil
-}
-
-func getTreeHeadCosigned(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Request) (int, error) {
- glog.V(3).Info("handling get-tree-head-cosigned request")
- cth, err := i.Stateman.Cosigned(ctx)
- if err != nil {
- return http.StatusInternalServerError, err
- }
- if err := cth.MarshalASCII(w); err != nil {
- return http.StatusInternalServerError, err
- }
- return http.StatusOK, nil
-}
-
-func getConsistencyProof(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) {
- glog.V(3).Info("handling get-consistency-proof request")
- req, err := i.consistencyProofRequestFromHTTP(r)
- if err != nil {
- return http.StatusBadRequest, err
- }
-
- proof, err := i.Client.GetConsistencyProof(ctx, req)
- if err != nil {
- return http.StatusInternalServerError, err
- }
- if err := proof.MarshalASCII(w); err != nil {
- return http.StatusInternalServerError, err
- }
- return http.StatusOK, nil
-}
-
-func getInclusionProof(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) {
- glog.V(3).Info("handling get-proof-by-hash request")
- req, err := i.inclusionProofRequestFromHTTP(r)
- if err != nil {
- return http.StatusBadRequest, err
- }
-
- proof, err := i.Client.GetInclusionProof(ctx, req)
- if err != nil {
- return http.StatusInternalServerError, err
- }
- if err := proof.MarshalASCII(w); err != nil {
- return http.StatusInternalServerError, err
- }
- return http.StatusOK, nil
-}
-
-func getLeaves(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.Request) (int, error) {
- glog.V(3).Info("handling get-leaves request")
- req, err := i.leavesRequestFromHTTP(r)
- if err != nil {
- return http.StatusBadRequest, err
- }
-
- leaves, err := i.Client.GetLeaves(ctx, req)
- if err != nil {
- return http.StatusInternalServerError, err
- }
- for _, leaf := range *leaves {
- if err := leaf.MarshalASCII(w); err != nil {
- return http.StatusInternalServerError, err
- }
- }
- return http.StatusOK, nil
-}