A comprehensive Go-based REST API with advanced monitoring and metrics capabilities.
.env fileAll of the endpoints are described in detail here
The project includes an interactive HTML dashboard (readme.html) that provides:
To use the dashboard:
readme.html in a web browsergo mod tidy
go build -o astelta-api-v2 main.go
./astelta-api-v2
Configure the API using environment variables or a .env file:
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
Full PostgreSQL connection string | - |
DB_HOST |
Database host | - |
DB_PORT |
Database port | - |
DB_USER |
Database username | - |
DB_PASSWORD |
Database password | - |
DB_NAME |
Database name | - |
CA_CERT_PATH |
Path to CA certificate for SSL | - |
Using DATABASE_URL:
DATABASE_URL="postgres://user:password@host:port/database?sslmode=require"
Using individual variables:
DB_HOST=localhost
DB_PORT=5432
DB_USER=myuser
DB_PASSWORD=mypassword
DB_NAME=mydatabase
# With environment variables
export DB_HOST=your-host
export DB_USER=your-user
export DB_PASSWORD=your-password
./astelta-api-v2
# Or with .env file
./astelta-api-v2
# Health check
curl http://localhost:8097/health
# Metrics
curl http://localhost:8097/metrics
# Database status
curl http://localhost:8097/db-status
.
├── main.go # Main application file
├── readme.html # Interactive metrics dashboard
├── .gitignore # Git ignore rules
├── go.mod # Go module file
├── go.sum # Go dependencies
└── .env # Environment configuration (ignored)
func myHandler(w http.ResponseWriter, r *http.Request) {
// Handler logic
}
main():
http.HandleFunc("/my-endpoint", corsMiddleware(myHandler))
The API provides multiple levels of monitoring:
Use these endpoints with monitoring tools like Prometheus, Grafana, or custom dashboards.
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Built with Go and PostgreSQL