Plan independent BFF and adapt selected Sendico foundations (#34)

This commit is contained in:
Stephan D committed 2026-09-12 13:11:10 +02:00
1 parent 1e191fca42
commit 45666d33fc
17 files changed
+854 -15

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
package main
import (
"context"
"errors"
"log/slog"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"git.sendico.io/tech/sxchnge/bff/internal/httpapi"
)
func main() {
if err := run(); err != nil {
slog.Error("BFF stopped", "error", err)
os.Exit(1)
}
}
func run() error {
addr := os.Getenv("SXCHNGE_HTTP_ADDR")
if addr == "" {
addr = "127.0.0.1:8082"
}
server := &http.Server{Addr: addr, Handler: httpapi.New(), ReadHeaderTimeout: 5 * time.Second, ReadTimeout: 15 * time.Second, WriteTimeout: 15 * time.Second, IdleTimeout: 60 * time.Second, MaxHeaderBytes: 1 << 20}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
failures := make(chan error, 1)
go func() { failures <- server.ListenAndServe() }()
slog.Info("BFF operational shell starting", "address", addr, "provider_configured", false)
select {
case err := <-failures:
if errors.Is(err, http.ErrServerClosed) {
return nil
}
return err
case <-ctx.Done():
shutdown, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
slog.Info("BFF shutting down")
return server.Shutdown(shutdown)
}
}