From 0974f6e2c055d8d06b5ea9c175252b22b2399fe2 Mon Sep 17 00:00:00 2001 From: S7evinK Date: Mon, 19 Oct 2020 10:38:10 +0200 Subject: [PATCH] Fix internal http api (#1535) Signed-off-by: Till Faelligen --- userapi/inthttp/server.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/userapi/inthttp/server.go b/userapi/inthttp/server.go index e24aad3a9..81e936e58 100644 --- a/userapi/inthttp/server.go +++ b/userapi/inthttp/server.go @@ -39,7 +39,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) { return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), ) - internalAPIMux.Handle(PerformAccountCreationPath, + internalAPIMux.Handle(PerformPasswordUpdatePath, httputil.MakeInternalAPI("performPasswordUpdate", func(req *http.Request) util.JSONResponse { request := api.PerformPasswordUpdateRequest{} response := api.PerformPasswordUpdateResponse{} @@ -169,7 +169,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) { return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), ) - internalAPIMux.Handle(QueryDeviceInfosPath, + internalAPIMux.Handle(QuerySearchProfilesPath, httputil.MakeInternalAPI("querySearchProfiles", func(req *http.Request) util.JSONResponse { request := api.QuerySearchProfilesRequest{} response := api.QuerySearchProfilesResponse{} @@ -182,4 +182,17 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) { return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), ) + internalAPIMux.Handle(InputAccountDataPath, + httputil.MakeInternalAPI("inputAccountDataPath", func(req *http.Request) util.JSONResponse { + request := api.InputAccountDataRequest{} + response := api.InputAccountDataResponse{} + if err := json.NewDecoder(req.Body).Decode(&request); err != nil { + return util.MessageResponse(http.StatusBadRequest, err.Error()) + } + if err := s.InputAccountData(req.Context(), &request, &response); err != nil { + return util.ErrorResponse(err) + } + return util.JSONResponse{Code: http.StatusOK, JSON: &response} + }), + ) }