major change of websocket dbmHandler structure
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user