2026-09-23 09:40:59 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
|
2026-10-01 16:54:35 +08:00
|
|
|
"github.com/havline/havline/internal/config"
|
|
|
|
|
"github.com/havline/havline/internal/version"
|
2026-09-23 09:40:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type versionResponse struct {
|
2026-10-01 16:54:35 +08:00
|
|
|
Version string `json:"version"`
|
|
|
|
|
NginxHTTPPort int `json:"nginx_http_port"`
|
|
|
|
|
NginxHTTPSPort int `json:"nginx_https_port"`
|
2026-09-23 09:40:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Version(cfg config.Config) http.HandlerFunc {
|
|
|
|
|
return func(w http.ResponseWriter, _ *http.Request) {
|
|
|
|
|
writeJSON(w, http.StatusOK, versionResponse{
|
|
|
|
|
Version: version.Version,
|
|
|
|
|
NginxHTTPPort: cfg.NginxDefaultHTTPPort,
|
|
|
|
|
NginxHTTPSPort: cfg.NginxDefaultHTTPSPort,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|