From f3e46af0d6668730bf515c1a0d0bc244c5213ac6 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Sun, 22 Aug 2021 18:37:38 +0200 Subject: [PATCH] Add missing internal api endpoint Signed-off-by: Till Faelligen --- userapi/inthttp/server.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/userapi/inthttp/server.go b/userapi/inthttp/server.go index 1c1cfdcd..b5db2928 100644 --- a/userapi/inthttp/server.go +++ b/userapi/inthttp/server.go @@ -16,6 +16,7 @@ package inthttp import ( "encoding/json" + "fmt" "net/http" "github.com/gorilla/mux" @@ -234,4 +235,18 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) { return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), ) + internalAPIMux.Handle(QueryKeyBackupPath, + httputil.MakeInternalAPI("queryKeyBackup", func(req *http.Request) util.JSONResponse { + request := api.QueryKeyBackupRequest{} + response := api.QueryKeyBackupResponse{} + if err := json.NewDecoder(req.Body).Decode(&request); err != nil { + return util.MessageResponse(http.StatusBadRequest, err.Error()) + } + s.QueryKeyBackup(req.Context(), &request, &response) + if response.Error != "" { + return util.ErrorResponse(fmt.Errorf("QueryKeyBackup: %s", response.Error)) + } + return util.JSONResponse{Code: http.StatusOK, JSON: &response} + }), + ) }