simple and clean RESTful API built with Go using net/http and gorilla/mux.
This project demonstrates a minimal backend architecture with routing, middleware, and CRUD endpoints.
This project was created to demonstrate backend fundamentals in Go, including:
- HTTP server setup
- Routing and middleware
- REST API principles
- Clean code organization
- RESTful API design
- Gorilla Mux router
- In-memory data store
- Logging middleware
- Clean project structure
go-mini-rest-api/
├─ cmd/server/main.go
├─ internal/
│ ├─ handlers/
│ ├─ routes/
│ ├─ models/
│ └─ middleware/
├─ go.mod
└─ README.md
You need to have Go 1.20 or newer version installed.
- GO
- net/http
- gorilla/mux
- curl
To Run The server:
go run cmd/server/main.goProject run on localhost:8080 port. So you can check the given url below from any of your web browser:
http://localhost:8080
GET /todos
Sample Response:
[
{
"id": 1,
"title": "Learn Go",
"completed": false
}
]POST /todos
Sample request body:
{
"title": "Build portfolio",
"completed": false
}GET /todos/{id}To view the available TODO tasks in JSON format, run the following curl command in the terminal:
curl http://localhost:8080/todosTo add a new TODO task:
# Create todo
curl -X POST http://localhost:8080/todos \
-H "Content-Type: application/json" \
-d '{"title":"Build portfolio","completed":false}'Get a todo by ID:
# Get todo by id
curl http://localhost:8080/todos/1
- Update / Delete Endpoints
- Unit Testing
- Docker file