Skip to content

Comments

Added new API service with GET and POST methods#20

Open
Sebastianfiet wants to merge 1 commit intoandy89923:mainfrom
Sebastianfiet:main
Open

Added new API service with GET and POST methods#20
Sebastianfiet wants to merge 1 commit intoandy89923:mainfrom
Sebastianfiet:main

Conversation

@Sebastianfiet
Copy link

Overview
This Pull Request adds a new API service to the nf-example repository. The service includes two HTTP methods: GET and POST.

Details of Changes
Created a new API service:

Added a GET method at /myservice/hello which returns a welcome message.

Added a POST method at /myservice/data that accepts a JSON payload with name and status, processes the data, and returns a confirmation message.

Code Modifications:

router.go: Modified to register the new routes for the GET and POST methods.

nfcfg.yaml: Updated service binding configurations to ensure proper setup for the new API.

New service logic: Created in the relevant service and API files for handling incoming GET and POST requests.

Testing
GET Method: Successfully tested the GET method by sending a request to http://127.0.0.1:8000/myservice/hello, which returned the expected welcome message.

POST Method: Tested the POST method using curl and PowerShell, sending a JSON payload with name and status, and confirmed the response was correct with status 200 OK and the expected output.

Impact
This update introduces a simple API service for testing and future use cases.

It provides a foundation for adding more services in the future if needed.

Notes
The implementation is intended for testing purposes and is based on the structure of the existing codebase.

The POST method processes basic data and responds with the received values for confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant