GoREST Status Plugin

Status check endpoint plugin for GoREST framework.
Installation
go get github.com/nicolasbonnici/gorest-status
Usage
import (
"github.com/nicolasbonnici/gorest/pluginloader"
statusplugin "github.com/nicolasbonnici/gorest-status"
)
func init() {
pluginloader.RegisterPluginFactory("status", statusplugin.NewPlugin)
}
Configuration
Add to your gorest.yaml:
plugins:
- name: status
enabled: true
Advanced Configuration
You can customize the endpoint path using plugin configuration:
plugins:
- name: status
enabled: true
config:
endpoint: "health" # Custom endpoint path (default: "status")
Configuration Parameters:
endpoint (string): Custom path for the health check endpoint. Default: "status"
- Example:
"health" creates endpoint at /health
- Example:
"api/status" creates endpoint at /api/status
Port Detection:
The plugin automatically detects the server port for logging purposes using the following priority:
port parameter in plugin config (if provided)
PORT environment variable
GOREST_PORT environment variable
- Fiber app configuration
- Default:
8080
Example with explicit port:
plugins:
- name: status
enabled: true
config:
endpoint: "health"
port: "3000" # Optional: override automatic detection
Features
- Customizable status check endpoint (default:
/status)
- Database connectivity check
- Returns HTTP 200 when healthy
- Returns HTTP 503 when database is down
- JSON response format
- Startup logging with endpoint URL
Healthy (database configured and up):
{
"status": "healthy",
"database": {
"status": "up"
}
}
Unhealthy (database down):
{
"status": "unhealthy",
"database": {
"status": "down",
"error": "connection failed"
}
}
Database not configured:
{
"status": "healthy",
"database": {
"status": "not_configured"
}
}
License
MIT License - see LICENSE file for details