https://github.com/jmrashed/go-todo-rest-api-example
Go-MySQL-Todo-Rest-API-Example is a sample project showcasing how to build a RESTful API for a Todo application using Go, MySQL and Gin framework.
https://github.com/jmrashed/go-todo-rest-api-example
Last synced: 9 months ago
JSON representation
Go-MySQL-Todo-Rest-API-Example is a sample project showcasing how to build a RESTful API for a Todo application using Go, MySQL and Gin framework.
- Host: GitHub
- URL: https://github.com/jmrashed/go-todo-rest-api-example
- Owner: jmrashed
- Created: 2023-05-04T23:52:31.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-05T01:49:34.000Z (about 3 years ago)
- Last Synced: 2025-07-26T04:26:27.327Z (11 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Todo REST API Example With Docker
A RESTful API example for simple todo application with Go
It is a just simple tutorial or example for making simple RESTful API with Go using **gorilla/mux** (A nice mux library) and **gorm** (An ORM for Go)
## Installation & Run
```bash
# Download this project
go get github.com/jmrashed/go-todo-rest-api-example
```
visit docker [jmrashed/go-todo-rest-api-example](https://hub.docker.com/r/jmrashed/go-todo-rest-api-example)
Before running API server, you should set the database config with yours or set the your database config with my values on [config.go](https://github.com/jmrashed/go-todo-rest-api-example/blob/master/config/config.go)
```go
func GetConfig() *Config {
return &Config{
DB: &DBConfig{
Dialect: "mysql",
Username: "root",
Password: "password",
Name: "todoapp",
Charset: "utf8",
},
}
}
```
```bash
# Build and Run
cd go-todo-rest-api-example
go build
./go-todo-rest-api-example
# API Endpoint : http://127.0.0.1:3000
```
## Structure
```
├── app
│ ├── app.go
│ ├── handler // Our API core handlers
│ │ ├── common.go // Common response functions
│ │ ├── projects.go // APIs for Project model
│ │ └── tasks.go // APIs for Task model
│ └── model
│ └── model.go // Models for our application
├── config
│ └── config.go // Configuration
└── main.go
```
## API
#### /projects
* `GET` : Get all projects
* `POST` : Create a new project
#### /projects/:title
* `GET` : Get a project
* `PUT` : Update a project
* `DELETE` : Delete a project
#### /projects/:title/archive
* `PUT` : Archive a project
* `DELETE` : Restore a project
#### /projects/:title/tasks
* `GET` : Get all tasks of a project
* `POST` : Create a new task in a project
#### /projects/:title/tasks/:id
* `GET` : Get a task of a project
* `PUT` : Update a task of a project
* `DELETE` : Delete a task of a project
#### /projects/:title/tasks/:id/complete
* `PUT` : Complete a task of a project
* `DELETE` : Undo a task of a project
## Todo
- [x] Support basic REST APIs.
- [ ] Support Authentication with user for securing the APIs.
- [ ] Make convenient wrappers for creating API handlers.
- [ ] Write the tests for all APIs.
- [x] Organize the code with packages
- [ ] Make docs with GoDoc
- [ ] Building a deployment process