datarhei-dragonfork-core/http/handler/api/about.go
Zac Gaetano 671f64ca56
Some checks failed
tests / build (push) Failing after 2s
tests / build (pull_request) Failing after 2s
feat(branding): Dragon Fork identity for v0.1.0-dragonfork release
M5 / final M2-stack work. The fork now identifies itself unambiguously
in logs, the API, and the README without changing the Go module path
(internal imports stay at github.com/datarhei/core/v16 — see NOTES.md
for the rationale).

Identity surfaces:

- app/version.go gains Variant ('dragonfork') and Fork ('Datarhei —
  Dragon Fork') as vars (overridable via -ldflags for downstream
  re-packagers).
- api.About + the /api endpoint expose 'variant' and 'fork' fields;
  Swagger docs regenerated.
- Startup banner logs 'variant' + 'fork' alongside the existing
  application + version fields, so a TrueNAS sysadmin tail-following
  /var/log can tell at a glance which fork is running.

Documentation:

- README.md rewritten with a Dragon Fork header and Quick start; the
  upstream feature surface is summarised in 'From upstream Datarhei'
  with a clear additivity statement. Sample process JSON, multi-input
  pipeline guidance, link to the design + testing docs.
- NOTICE: Apache 2.0 §4(d) attribution to upstream datarhei Core,
  Pion, Echo, FFmpeg.
- CREDITS: enumerated dependency list with licenses.
- CHANGELOG.md prepended with a 'Datarhei — Dragon Fork' section
  starting at v0.1.0-dragonfork; upstream's '# Core' history preserved
  below.

Module path stays github.com/datarhei/core/v16 by design — the fork is
distinguished by repo location and branch history, not import path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 12:22:25 +00:00

60 lines
1.5 KiB
Go

package api
import (
"net/http"
"time"
"github.com/datarhei/core/v16/app"
"github.com/datarhei/core/v16/http/api"
"github.com/datarhei/core/v16/restream"
"github.com/labstack/echo/v4"
)
// The AboutHandler type provides handler functions for retrieving details
// about the API version and build infos.
type AboutHandler struct {
restream restream.Restreamer
auths []string
}
// NewAbout returns a new About type
func NewAbout(restream restream.Restreamer, auths []string) *AboutHandler {
return &AboutHandler{
restream: restream,
auths: auths,
}
}
// About returns API version and build infos
// @Summary API version and build infos
// @Description API version and build infos in case auth is valid or not required. If auth is required, just the name field is populated.
// @ID about
// @Produce json
// @Success 200 {object} api.About
// @Security ApiKeyAuth
// @Router /api [get]
func (p *AboutHandler) About(c echo.Context) error {
createdAt := p.restream.CreatedAt()
about := api.About{
App: app.Name,
Variant: app.Variant,
Fork: app.Fork,
Name: p.restream.Name(),
Auths: p.auths,
ID: p.restream.ID(),
CreatedAt: createdAt.Format(time.RFC3339),
Uptime: uint64(time.Since(createdAt).Seconds()),
Version: api.Version{
Number: app.Version.String(),
Commit: app.Commit,
Branch: app.Branch,
Build: app.Build,
Arch: app.Arch,
Compiler: app.Compiler,
},
}
return c.JSON(http.StatusOK, about)
}