package models type Response struct { Error bool `json:"error,omitempty"` Message string `json:"message,omitempty"` Get []Get `json:"get,omitempty"` Set []Set `json:"set,omitempty"` Subscribe []Subscribe `json:"subscribe,omitempty"` Unsubscribe []Subscribe `json:"unsubscribe,omitempty"` Publish []Publish `json:"publish,omitempty"` } func NewResponse() *Response { return &Response{} } func (r *Response) SendError(msg string) { r.Error = true r.Message = msg } func (r *Response) AddGet(get Get) { get.Query = nil r.Get = append(r.Get, get) } func (r *Response) AddSet(set Set) { r.Set = append(r.Set, set) } func (r *Response) AddSubscription(sub Subscribe) { r.Subscribe = append(r.Subscribe, sub) } func (r *Response) IsValid() bool { return !r.Error } func (r *Response) FetchGets() []Get { return r.Get } func (r *Response) FetchSets() []Set { return r.Set } func (r *Response) FetchSubscribes() []Subscribe { return r.Subscribe } func (r *Response) FetchUnubscribes() []Subscribe { return r.Unsubscribe } func (r *Response) FetchPublish() []Publish { return r.Publish }