Install docker and run command
docker-compose up
to start docker and access http://localhost:8081/
for Mongo Express database management dashboard
Run command go run main.go
to start application
-
POST /repositories
: creates a new repository
How to test
endpointhttp://localhost:8080/repositories'
request body example
{ "name": "test name 3", "url": "https://github.com/Thalerngsak/apitest.git" }
-
GET /repositories
: retrieves all repositories
How to test
endpointhttp://localhost:8080/repositories'
-
GET /repositories/:id
: retrieves a single repository by ID
How to test
endpoint examplehttp://localhost:8080/repositories/af1a94c4-8882-424f-9fb4-b3976775a4eb'
-
PUT /repositories/:id
: updates a repository by ID
How to test
endpoint examplehttp://localhost:8080/repositories/af1a94c4-8882-424f-9fb4-b3976775a4eb'
request body example
{ "name": "test name 3", "url": "https://github.com/Thalerngsak/apitest.git" }
-
DELETE /repositories/:id
: deletes a repository by ID
How to test
endpoint examplehttp://localhost:8080/repositories/af1a94c4-8882-424f-9fb4-b3976775a4eb'
-
POST /scan-results
: scans a repository and creates a new scan result
How to test
endpoint examplehttp://localhost:8080/repositories/af1a94c4-8882-424f-9fb4-b3976775a4eb'
request body example
{ "id":"7ef1922f-7fd7-457f-bd20-377105dc95ba" }
-
GET /scan-results
: retrieves all scan results
How to test
endpoint examplehttp://localhost:8080/repositories/af1a94c4-8882-424f-9fb4-b3976775a4eb'
-
GET /results/repository/:id
: retrieves a single scan result by ID
How to test
endpoint examplehttp://localhost:8080/repositories/af1a94c4-8882-424f-9fb4-b3976775a4eb'
The application is designed using the Hexagonal Architecture pattern, which provides a clean separation between the business logic and the infrastructure code.
The database schema consists of two collections: "repositories" and "scan_results". The "repositories" collection stores the Repository entities, while the "scan_results" collection stores the ScanResult entities.
Overall, this design provides a clean separation between the different components of the application, making it easy to test, maintain, and extend.
- Gin as the web framework
- MongoDB as the database for storing repository and scan result data