36 lines
645 B
Go
36 lines
645 B
Go
package models
|
|
|
|
type JsonData struct {
|
|
Get *[]Get `json:"get,omitempty"`
|
|
Set *[]Set `json:"set,omitempty"`
|
|
Subscribe *[]Subscribe `json:"subscribe,omitempty"`
|
|
Unsubscribe *[]Subscribe `json:"unsubscribe,omitempty"`
|
|
}
|
|
|
|
func NewRequest() *JsonData {
|
|
return &JsonData{}
|
|
|
|
}
|
|
|
|
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,
|
|
})
|
|
}
|
|
|
|
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,
|
|
})
|
|
}
|