major change of websocket dbmHandler structure

This commit is contained in:
Adrian Zürcher
2025-04-23 21:53:01 +02:00
parent a1f947e24a
commit 0a137c9d86
35 changed files with 1676 additions and 424 deletions

View File

@@ -1,21 +1,35 @@
package models
type JsonData struct {
Get *[]Get `json:"get,omitempty"`
Set *[]Set `json:"set,omitempty"`
Get *[]Get `json:"get,omitempty"`
Set *[]Set `json:"set,omitempty"`
Subscribe *[]Subscribe `json:"subscribe,omitempty"`
Unsubscribe *[]Subscribe `json:"unsubscribe,omitempty"`
}
type Get struct {
Path string `json:"path"`
Query *Query `json:"query,omitempty"`
func NewRequest() *JsonData {
return &JsonData{}
}
type Set struct {
Path string `json:"path"`
Value any `json:"value"`
func (r *JsonData) AddGet(path string, query Query) {
if r.Get == nil {
r.Get = &[]Get{}
}
*r.Get = append(*r.Get, Get{
Path: path,
Query: &query,
})
}
type Query struct {
Depth int `json:"depth,omitempty"`
RegExp string `json:"regExp,omitempty"`
func (r *JsonData) AddSet(path string, value any, create bool) {
if r.Set == nil {
r.Set = &[]Set{}
}
*r.Set = append(*r.Set, Set{
Path: path,
Value: value,
})
}