feat: add /autocompleter endpoint for search suggestions
Proxies to upstream SearXNG /autocompleter if configured, otherwise falls back to Wikipedia OpenSearch API. Returns a JSON array of suggestion strings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
90810cb934
commit
9b280ad606
3 changed files with 157 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/autocomplete"
|
||||
"github.com/metamorphosis-dev/kafka/internal/cache"
|
||||
"github.com/metamorphosis-dev/kafka/internal/config"
|
||||
"github.com/metamorphosis-dev/kafka/internal/httpapi"
|
||||
|
|
@ -57,12 +58,15 @@ func main() {
|
|||
Cache: searchCache,
|
||||
})
|
||||
|
||||
h := httpapi.NewHandler(svc)
|
||||
acSvc := autocomplete.NewService(cfg.Upstream.URL, cfg.HTTPTimeout())
|
||||
|
||||
h := httpapi.NewHandler(svc, acSvc.Suggestions)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", h.Index)
|
||||
mux.HandleFunc("/healthz", h.Healthz)
|
||||
mux.HandleFunc("/search", h.Search)
|
||||
mux.HandleFunc("/autocompleter", h.Autocompleter)
|
||||
mux.HandleFunc("/opensearch.xml", h.OpenSearch(cfg.Server.BaseURL))
|
||||
|
||||
// Serve embedded static files (CSS, JS, images).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue