Skip to content

Commit

Permalink
DELETE still in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
tabitapetruneac committed Sep 9, 2024
1 parent a77907a commit 0d22273
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (app *App) DeleteUser(w http.ResponseWriter, r *http.Request) {
return
}

userID := r.URL.Query().Get("id")
userID := r.URL.Query().Get("user_id")
if userID == "" {
http.NotFound(w, r)
return
Expand Down
14 changes: 10 additions & 4 deletions bff/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ def signupuser():
r = requests.post(f'http://{IP}:{PORT}/signup', request.form, headers=request.headers)
return render_template('view/home.html')

@app.route('/user/<int:id>', methods=['DELETE'])
def delete_user(id):
url = f"http://{IP}:{PORT}/user/{id}"
@app.route('/user', methods=['DELETE'])
def delete_user():
user_id = request.args.get('id')

if not user_id:
app.logger.error("user id is missing")
return jsonify({'error': 'user id required'}), 400

url = f"http://{IP}:{PORT}/user/{user_id}"
app.logger.info(f"Sending DELETE request to {url}")
try:
response = requests.delete(url)
Expand All @@ -125,7 +131,7 @@ def delete_user(id):
except requests.exceptions.RequestException as req_err:
app.logger.error(f"Request error occurred: {req_err}")
return jsonify({'error': 'User deletion failed', 'details': str(req_err)}), 500
return '', 204
return jsonify({'message': f'User {user_id} delete successfully'}), 200


if __name__=='__main__':
Expand Down

0 comments on commit 0d22273

Please sign in to comment.