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
33 lines
823 B
Go
33 lines
823 B
Go
package engines
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
// NewDefaultPortedEngines returns the starter set of Go-native engines.
|
|
// The service can swap/extend this registry later as more engines are ported.
|
|
func NewDefaultPortedEngines(client *http.Client) map[string]Engine {
|
|
if client == nil {
|
|
client = &http.Client{Timeout: 10 * time.Second}
|
|
}
|
|
|
|
return map[string]Engine{
|
|
"wikipedia": &WikipediaEngine{client: client},
|
|
"arxiv": &ArxivEngine{client: client},
|
|
"crossref": &CrossrefEngine{client: client},
|
|
"braveapi": &BraveEngine{
|
|
client: client,
|
|
apiKey: os.Getenv("BRAVE_API_KEY"),
|
|
accessGateToken: os.Getenv("BRAVE_ACCESS_TOKEN"),
|
|
resultsPerPage: 20,
|
|
},
|
|
"qwant": &QwantEngine{
|
|
client: client,
|
|
category: "web-lite",
|
|
resultsPerPage: 10,
|
|
},
|
|
}
|
|
}
|
|
|