mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
type channelCatalogItem struct {
|
|
Name string `json:"name"`
|
|
ConfigKey string `json:"config_key"`
|
|
Variant string `json:"variant,omitempty"`
|
|
}
|
|
|
|
var channelCatalog = []channelCatalogItem{
|
|
{Name: "weixin", ConfigKey: "weixin"},
|
|
{Name: "telegram", ConfigKey: "telegram"},
|
|
{Name: "discord", ConfigKey: "discord"},
|
|
{Name: "slack", ConfigKey: "slack"},
|
|
{Name: "feishu", ConfigKey: "feishu"},
|
|
{Name: "dingtalk", ConfigKey: "dingtalk"},
|
|
{Name: "line", ConfigKey: "line"},
|
|
{Name: "qq", ConfigKey: "qq"},
|
|
{Name: "onebot", ConfigKey: "onebot"},
|
|
{Name: "wecom", ConfigKey: "wecom"},
|
|
{Name: "wecom_app", ConfigKey: "wecom_app"},
|
|
{Name: "wecom_aibot", ConfigKey: "wecom_aibot"},
|
|
{Name: "whatsapp", ConfigKey: "whatsapp", Variant: "bridge"},
|
|
{Name: "whatsapp_native", ConfigKey: "whatsapp", Variant: "native"},
|
|
{Name: "pico", ConfigKey: "pico"},
|
|
{Name: "maixcam", ConfigKey: "maixcam"},
|
|
{Name: "matrix", ConfigKey: "matrix"},
|
|
{Name: "irc", ConfigKey: "irc"},
|
|
}
|
|
|
|
// registerChannelRoutes binds read-only channel catalog endpoints to the ServeMux.
|
|
func (h *Handler) registerChannelRoutes(mux *http.ServeMux) {
|
|
mux.HandleFunc("GET /api/channels/catalog", h.handleListChannelCatalog)
|
|
}
|
|
|
|
// handleListChannelCatalog returns the channels supported by backend.
|
|
//
|
|
// GET /api/channels/catalog
|
|
func (h *Handler) handleListChannelCatalog(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(map[string]any{
|
|
"channels": channelCatalog,
|
|
})
|
|
}
|