package main import ( "log" "net/http" "os" "time" "github.com/ashie/gosearch/internal/httpapi" "github.com/ashie/gosearch/internal/search" ) func main() { port := os.Getenv("PORT") if port == "" { port = "8080" } upstreamURL := os.Getenv("UPSTREAM_SEARXNG_URL") timeout := 10 * time.Second if v := os.Getenv("HTTP_TIMEOUT"); v != "" { if d, err := time.ParseDuration(v); err == nil { timeout = d } } svc := search.NewService(search.ServiceConfig{ UpstreamURL: upstreamURL, HTTPTimeout: timeout, }) h := httpapi.NewHandler(svc) mux := http.NewServeMux() mux.HandleFunc("/healthz", h.Healthz) mux.HandleFunc("/search", h.Search) addr := ":" + port log.Printf("searxng-go listening on %s", addr) log.Fatal(http.ListenAndServe(addr, mux)) }