Scaffolds the server module and everything Phase 0 of PLAN.md calls for: a binary that boots, serves its discovery endpoints and nothing else yet. - config: one YAML file plus per-field WARP_* environment overrides, unknown fields rejected, validation that reports every problem at once - logging and metrics: slog, a Prometheus registry, per-route HTTP instrumentation labelled by pattern rather than path - httputil: the Matrix error envelope, error-returning handlers, CORS, request logging, panic recovery, and a router over http.ServeMux - endpoints: /_matrix/client/versions, /.well-known/matrix/client, /.well-known/matrix/server (gated), /healthz, /metrics, and M_UNRECOGNIZED for everything else - storage: driver registry, shared database/sql base, checksummed migration runner, sqlite and postgres drivers, pocketbase stub - settings: server_settings table behind a cached service, so the federation and registration switches change without a restart - federation: the gate that makes federation a runtime mode - cmd/warp: serve, migrate, generate-keys, version - Makefile, golangci-lint v2, GitHub Actions CI (Linux and Windows tests, race on Linux, storage tests against PostgreSQL, lint, boot smoke test), Dockerfile, example config and docs Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
23 lines
501 B
Go
23 lines
501 B
Go
package config
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
// unmarshalStrict decodes YAML into v and rejects unknown fields, so a typo
|
|
// in warp.yaml fails the boot instead of being silently ignored.
|
|
func unmarshalStrict(data []byte, v any) error {
|
|
dec := yaml.NewDecoder(bytes.NewReader(data))
|
|
dec.KnownFields(true)
|
|
if err := dec.Decode(v); err != nil {
|
|
// An empty file decodes to io.EOF; treat it as "all defaults".
|
|
if err.Error() == "EOF" {
|
|
return nil
|
|
}
|
|
return err
|
|
}
|
|
return nil
|
|
}
|