diff --git a/dapr-distributed-calendar/locust/main.py b/dapr-distributed-calendar/locust/main.py index 1d9a528..9f361d1 100644 --- a/dapr-distributed-calendar/locust/main.py +++ b/dapr-distributed-calendar/locust/main.py @@ -43,11 +43,10 @@ def event_lifecycle(self): updated_data = { "data": { "name": f"Updated Event {event_id}", - "date": "2020-10-10", - "id": str(event_id) + "date": "2020-10-10" } } - response = self.client.put(f'/updateevent', json=updated_data, headers=headers) + response = self.client.put(f'/updateevent/{event_id}', json=updated_data, headers=headers) # Check if the update was successful if response.status_code == 200: diff --git a/dapr-distributed-calendar/node/node_controller.js b/dapr-distributed-calendar/node/node_controller.js index f6270dc..76f410c 100644 --- a/dapr-distributed-calendar/node/node_controller.js +++ b/dapr-distributed-calendar/node/node_controller.js @@ -145,19 +145,25 @@ app.get('/event/:id', (req, res) =>{ }); }) -app.put('/updateevent', (req, res) => { +app.put('/updateevent/:id', (req, res) => { updateEventCounter.add(1); const data = req.body.data; - const eventId = data.id; - console.log("Updating event! Event ID: " + eventId); + const key = req.params.id; + const body = { + "name": data.name, + "date": data.date, + "id": key + } + + console.log("Updating event! Event ID: " + key); - console.log("Data passed as body to Go", JSON.stringify(data)) + console.log("Data passed as body to Go", JSON.stringify(body)) // Assuming your Go service has an endpoint like '/updateEvent' fetch(invokeUrl + `/updateEvent`, { method: "PUT", // Use PUT method for updating - body: JSON.stringify(data), + body: JSON.stringify(body), headers: { "Content-Type": "application/json" }