mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
2784223ad5
Default the sample web search provider to auto, route Sogou vs DuckDuckGo dynamically based on query/UI language, and sync frontend language changes back to the backend so Current Service and runtime selection stay aligned.
28 lines
624 B
Go
28 lines
624 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/tools"
|
|
)
|
|
|
|
type uiLanguageRequest struct {
|
|
Language string `json:"language"`
|
|
}
|
|
|
|
func (h *Handler) registerUIRoutes(mux *http.ServeMux) {
|
|
mux.HandleFunc("POST /api/ui/language", h.handleSetUILanguage)
|
|
}
|
|
|
|
func (h *Handler) handleSetUILanguage(w http.ResponseWriter, r *http.Request) {
|
|
var req uiLanguageRequest
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
http.Error(w, "invalid request body", http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
tools.SetPreferredWebSearchLanguage(req.Language)
|
|
w.WriteHeader(http.StatusNoContent)
|
|
}
|