This is a simple RESTful API built with Go using the Gin web framework and GORM for database interactions. The API allows for creating and retrieving posts.
- Create new post
- Get post by id
- Edit post by id
- Delete post by id
- Retrieve all posts
- Clone the repository:
git clone https://github.com/senja24/golang-api.git
cd golang-api- Install dependencies
- Set up database
- Run the application:
go run main.go- Get all posts
GET /api/posts- Create a new post
POST /api/posts- Get post by id
GET /api/posts/:id- Edit post by id
PUT /api/posts/:id- Delete post by id
DELETE /api/posts/:id. ├── controllers │ └── postsController.go ├── models │ ├── post.go │ └── setup.go ├── main.go └── go.mod