package main

import (
	"log/slog"
	"net/http"
	"os"
	"strings"
	"time"

	"github.com/easyai/easyai-ai-gateway/apps/api/internal/acceptanceemulator"
)

func main() {
	address := strings.TrimSpace(os.Getenv("HTTP_ADDR"))
	if address == "" {
		address = ":8090"
	}
	server := &http.Server{
		Addr:              address,
		Handler:           acceptanceemulator.New(acceptanceemulator.Config{}).Handler(),
		ReadHeaderTimeout: 10 * time.Second,
	}
	slog.Info("acceptance protocol emulator started", "address", address)
	if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
		slog.Error("acceptance protocol emulator stopped", "error", err)
		os.Exit(1)
	}
}
