Documentation ¶
Index ¶
Constants ¶
View Source
const ( TypeMap = iota TypeArray TypePaginator )
Variables ¶
View Source
var ( DefaultWrapKey = "data" DefaultAppendKey = "meta" )
Functions ¶
Types ¶
type JsonResource ¶
type JsonResource struct {
// contains filtered or unexported fields
}
JsonResource is a resource that can be marshalled to JSON.
func NewArray ¶
func NewArray(c *gin.Context, resource Resource) *JsonResource
NewArray returns a new JsonResource with Array type
func NewMap ¶
func NewMap(c *gin.Context, resource Resource) *JsonResource
NewMap returns a new JsonResource with Map type
func NewPaginator ¶
func NewPaginator(c *gin.Context, resource Resource) *JsonResource
NewPaginator returns a new JsonResource with Paginator type
func (*JsonResource) Append ¶
func (r *JsonResource) Append(obj gin.H) *JsonResource
Append adds a new key-value pair to the resource
func (*JsonResource) MarshalJSON ¶
func (r *JsonResource) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*JsonResource) Response ¶
func (r *JsonResource) Response()
Response returns the resource as a response.
func (*JsonResource) Wrap ¶
func (r *JsonResource) Wrap(name string) *JsonResource
Warp sets the wrap name for the resource
Click to show internal directories.
Click to hide internal directories.