OrangePi3588Media/agent/internal/httpapi/models_status.go

21 lines
539 B
Go

package httpapi
import "net/http"
func (s *Server) handleModelsStatus(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
errorJSON(w, http.StatusMethodNotAllowed, "method not allowed")
return
}
if !s.authorize(r, false) {
errorJSON(w, http.StatusUnauthorized, "unauthorized")
return
}
items, err := s.store.ListInstalledModels()
if err != nil {
errorJSON(w, http.StatusInternalServerError, "internal error: "+err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"models": items})
}