https://github.com/anazcodes/signalzero
https://github.com/anazcodes/signalzero
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/anazcodes/signalzero
- Owner: anazcodes
- Created: 2024-03-27T19:58:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T20:35:18.000Z (over 2 years ago)
- Last Synced: 2024-12-01T04:15:40.399Z (over 1 year ago)
- Language: Go
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Assessment
===
Implement 2 API endpoints using the Gin framework, and the endpoints should store and retrieve data from MongoDB.
## Requirements
### POST API
- Send the user details such as user_id, username, password in the request body.
- Receive it on the backend, then insert it into a MongoDB collection.
##### Request
```
curl --location 'http://localhost:8080/' \
--header 'Content-Type: application/json' \
--data '{
"user_id":"1",
"username":"new person",
"password":"1234"
}'
```
### GET API
- Retrieve username as a query parameter from the request.
- If the query is empty, show all users stored in the 'users' collection.
- If the query exists, retrieve all the users whose names start with the specified prefix.
- Give response with the retrieved user information.
##### Request
```
curl --location 'http://localhost:8080?username=new'
```
### Tested Platform
```
OS: Ubuntu LTS
Go: version go1.22.1 linux/amd64
```