add files
This commit is contained in:
37
jsonData.go
Normal file
37
jsonData.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package models
|
||||
|
||||
type JsonData struct {
|
||||
Get *[]Get `json:"get,omitempty"`
|
||||
Set *[]Set `json:"set,omitempty"`
|
||||
Subscribe *[]Subscribe `json:"subscribe,omitempty"`
|
||||
Subscribed *[]Subscribed `json:"subscribed,omitempty"`
|
||||
Unsubscribe *[]Subscribe `json:"unsubscribe,omitempty"`
|
||||
Publish *[]Publish `json:"publish,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,
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user