feat: build Go-based SearXNG-compatible search service
Implement an API-first Go rewrite with local engine adapters, upstream fallback, and Nix-based tooling so searches can run without matching the original UI while preserving response compatibility. Made-with: Cursor
This commit is contained in:
parent
7783367c71
commit
dc44837219
32 changed files with 3330 additions and 0 deletions
43
cmd/searxng-go/main.go
Normal file
43
cmd/searxng-go/main.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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))
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue