Files
beacon-server/internal/api/info.go
T
MrAlders0n 9bbf8efee5 release: v2.0.4 (#217)
* perf(routes): batch cross-IATA and hash route search (#216)

One search fired a /routes/cross request per IATA pair (138k on 2026-10-08). Route search now takes an optional iatas list and runs a fixed number of index-backed queries. /info advertises built-in minimum client versions.

* chore: bump version to 2.0.4
2026-10-09 22:17:23 -04:00

49 lines
1.3 KiB
Go

// Copyright 2026 Beacon Contributors
// SPDX-License-Identifier: AGPL-3.0-or-later
package api
import (
"strconv"
"strings"
)
// Client floors this server code needs. Bump the matching one when a release breaks older
// clients; config can raise them, never lower them. Empty means no requirement.
const (
MinAppVersion = "" // BEACON Mobile
MinWebVersion = "2.0.3" // Beacon Web: batched route search
)
// Info is the public server description clients check before using a server.
type Info struct {
// MinAppVersion is the oldest allowed app version (X.Y.Z); null means no requirement.
MinAppVersion *string `json:"minAppVersion" example:"0.1.1"`
// MinWebVersion is the oldest allowed Beacon Web version (X.Y.Z); null means no requirement.
MinWebVersion *string `json:"minWebVersion" example:"2.0.3"`
ServerVersion string `json:"serverVersion" example:"2.0.2"`
}
// HigherVersion returns the newer of two X.Y.Z versions; empty sorts oldest.
func HigherVersion(a, b string) string {
if versionLess(a, b) {
return b
}
return a
}
func versionLess(a, b string) bool {
if a == "" || b == "" {
return a == "" && b != ""
}
pa, pb := strings.Split(a, "."), strings.Split(b, ".")
for i := 0; i < len(pa) && i < len(pb); i++ {
x, _ := strconv.Atoi(pa[i])
y, _ := strconv.Atoi(pb[i])
if x != y {
return x < y
}
}
return len(pa) < len(pb)
}