Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new REST API endpoint /iseven that determines whether a submitted number is even or odd, returning HTTP status codes based on the result.
- Introduces a new POST endpoint
/iseventhat accepts JSON input with a number field - Returns HTTP 200 for even numbers and HTTP 400 for odd numbers
- Includes error handling for malformed requests
| return 400 | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"Error processing hello request: {str(e)}") |
There was a problem hiding this comment.
Error message incorrectly references 'hello request' instead of 'iseven request'
| logger.error(f"Error processing hello request: {str(e)}") | |
| logger.error(f"Error processing iseven request: {str(e)}") |
| if number % 2 == 0: | ||
| return 200 | ||
| else | ||
| return 400 |
There was a problem hiding this comment.
Direct dictionary access will raise KeyError if 'number' key is missing. Consider using data.get('number') or add key validation
| return 400 | |
| if not data or "number" not in data: | |
| return jsonify({"error": "Missing 'number' field in JSON payload"}), 400 | |
| number = data["number"] | |
| if number % 2 == 0: | |
| return '', 200 | |
| else: | |
| return '', 400 |
| if number % 2 == 0: | ||
| return 200 | ||
| else | ||
| return 400 |
There was a problem hiding this comment.
[nitpick] Returning bare status codes without response body is inconsistent with other endpoints. Consider returning jsonify({'result': 'even'}) for consistency
| return 400 | |
| return jsonify({"result": "even"}), 200 | |
| else: | |
| return jsonify({"result": "odd"}), 400 |
Docker Image BuiltImage: Pull the image: docker pull ghcr.io/bruj0/cicd-for-eks/ping-pong:pr-3-20250812-120437,ghcr.io/bruj0/cicd-for-eks/ping-pong:feature-adding-iseven-latestDeploy with Helm: helm upgrade --install ping-pong ./helm-charts/ping-pong \
--set image.repository=bruj0/cicd-for-eks/ping-pong \
--set image.tag=pr-3-20250812-120437 |
No description provided.