Implemented Create Pusher

This commit is contained in:
Dan Peleg 2021-05-02 17:11:53 +03:00
parent 024afaba7c
commit 4c4cf8020a
10 changed files with 110 additions and 2 deletions

View file

@ -29,6 +29,7 @@ const (
InputAccountDataPath = "/userapi/inputAccountData"
PerformDeviceCreationPath = "/userapi/performDeviceCreation"
PerformPusherCreationPath = "/userapi/performPusherCreation"
PerformAccountCreationPath = "/userapi/performAccountCreation"
PerformPasswordUpdatePath = "/userapi/performPasswordUpdate"
PerformDeviceDeletionPath = "/userapi/performDeviceDeletion"
@ -124,6 +125,18 @@ func (h *httpUserInternalAPI) PerformDeviceDeletion(
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
func (h *httpUserInternalAPI) PerformPusherCreation(
ctx context.Context,
request *api.PerformPusherCreationRequest,
response *api.PerformPusherCreationResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformPusherCreation")
defer span.Finish()
apiURL := h.apiURL + PerformPusherCreationPath
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
func (h *httpUserInternalAPI) PerformPusherDeletion(
ctx context.Context,
request *api.PerformPusherDeletionRequest,

View file

@ -52,6 +52,19 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
internalAPIMux.Handle(PerformPusherCreationPath,
httputil.MakeInternalAPI("performPusherCreation", func(req *http.Request) util.JSONResponse {
request := api.PerformPusherCreationRequest{}
response := api.PerformPusherCreationResponse{}
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
return util.MessageResponse(http.StatusBadRequest, err.Error())
}
if err := s.PerformPusherCreation(req.Context(), &request, &response); err != nil {
return util.ErrorResponse(err)
}
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
internalAPIMux.Handle(PerformDeviceCreationPath,
httputil.MakeInternalAPI("performDeviceCreation", func(req *http.Request) util.JSONResponse {
request := api.PerformDeviceCreationRequest{}