A RESTful API built in Go using Gin and GORM, responsible for managing:
- Users (
Customer) - Articles (
Article) - Keywords (
Keyword)
.
├── cmd/server/main.go # Entry point
├── internal/ # Application core
│ ├── db/ # Database connection
│ ├── handler/ # HTTP handlers
│ ├── model/ # Data models
│ ├── repository/ # Database access (GORM)
│ ├── router/ # HTTP routes
│ └── service/ # Business logic
| Method | Route | Description |
|---|---|---|
| GET | /customer |
List all users |
| GET | /customer/:id |
Get user by ID |
| POST | /customer |
Create a new user |
| PUT | /customer/:id |
Update a user |
| DELETE | /customer/:id |
Delete a user |
| Method | Route | Description |
|---|---|---|
| GET | /article |
List all articles |
| GET | /article/:id |
Get article by ID |
| POST | /article |
Create a new article |
| PUT | /article/:id |
Update an article |
| DELETE | /article/:id |
Delete an article |
| GET | /article/customer/:customerId |
Get articles by user ID |
| GET | /article/title?title=... |
Search by title (LIKE) |
| GET | /article/content?content=... |
Search by content (LIKE) |
| GET | /article/keywords?kw=kw1&kw=kw2 |
Search articles containing any keyword |
| GET | /article/keywords/filter?kw=... |
Search articles containing all keywords |
| Method | Route | Description |
|---|---|---|
| GET | /keyword |
List all keywords |
| GET | /keyword/:id |
Get keyword by ID |
| POST | /keyword |
Create a new keyword |
| PUT | /keyword/:id |
Update a keyword |
| DELETE | /keyword/:id |
Delete a keyword |
| GET | /keyword/article/:articleId |
List keywords for an article |
- Set variables in
.env - Create the database using
articles_db.sql - Import requests using
requests.postman_collection.json - Run the app:
go run cmd/server/main.go