A lightweight RESTful API for managing employee records built with Go (standard library net/http) and Redis.
Repository: github.com/whalelogic/restgo
| Variable | Description | Default Value |
|---|---|---|
REDIS_ADDR |
Network address (host:port) of the Redis instance | localhost:6379 |
# Inline execution
REDIS_ADDR="127.0.0.1:6379" go run main.go
# Session-wide export
export REDIS_ADDR="127.0.0.1:6379"
The service listens on port :8080.
| Method | Endpoint | Description |
|---|---|---|
GET |
/employees |
List all employees |
GET |
/employees/{id} |
Get employee by ID |
POST |
/employees |
Create a new employee |
PUT |
/employees/{id} |
Fully update/replace an employee |
PATCH |
/employees/{id} |
Partially update an employee |
DELETE |
/employees/{id} |
Delete an employee |
Bash
curl -X GET http://localhost:8080/employees
Bash
curl -X GET http://localhost:8080/employees/emp_01J8
Bash
curl -X POST http://localhost:8080/employees \
-H "Content-Type: application/json" \
-d '{"name": "Alex Smith", "role": "DevOps", "email": "alex@example.com"}'
Bash
curl -X PUT http://localhost:8080/employees/emp_01J8 \
-H "Content-Type: application/json" \
-d '{"name": "Alex Smith", "role": "Lead DevOps", "email": "alex@example.com"}'
Bash
curl -X PATCH http://localhost:8080/employees/emp_01J8 \
-H "Content-Type: application/json" \
-d '{"role": "Principal DevOps"}'
Bash
curl -X DELETE http://localhost:8080/employees/emp_01J8
The routing maps directly to the employee.EmployeeHandler struct via Go's native standard library routing:
Go
mux := http.NewServeMux()
mux.HandleFunc("GET /employees", h.List)
mux.HandleFunc("GET /employees/{id}", h.Get)
mux.HandleFunc("POST /employees", h.Create)
mux.HandleFunc("PUT /employees/{id}", h.Update)
mux.HandleFunc("PATCH /employees/{id}", h.Patch)
mux.HandleFunc("DELETE /employees/{id}", h.Delete)