github.com/lovung/GoCleanArchitecture@v0.0.0-20210302152432-50d91fd29f9f/app/internal/interface/restful/presenter/base_presenter.go (about) 1 package presenter 2 3 import ( 4 "github.com/google/go-cmp/cmp" 5 ) 6 7 // Response represents the response of every request 8 type Response struct { 9 Meta MetaResponse `json:"meta,omitempty"` 10 Data interface{} `json:"data,omitempty"` 11 Errors ErrorResponses `json:"errors,omitempty"` 12 } 13 14 // IsEmpty check if the struct is empty or not 15 func (r Response) IsEmpty() bool { 16 return cmp.Equal(r, Response{}) 17 } 18 19 // MetaResponse represents meta-information 20 type MetaResponse struct { 21 Code int `json:"code,omitempty"` 22 Message string `json:"message,omitempty"` 23 Total uint64 `json:"total,omitempty"` 24 NextCursor string `json:"next_cursor,omitempty"` 25 PreviousCursor string `json:"previous_cursor,omitempty"` 26 } 27 28 // PagingRequest request 29 type PagingRequest struct { 30 Size uint64 `mapstructure:"size" json:"page[size]"` 31 Number uint64 `mapstructure:"number" json:"page[number]"` 32 } 33 34 // IDResponse represent the common data response for many requests 35 type IDResponse struct { 36 ID interface{} `json:"id,omitempty"` 37 }