Archived
2
0
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
kerma/models/generic.go
2023-03-02 15:28:43 +01:00

40 lines
840 B
Go

// Package models provides the models for the KermaGo application
package models
import "github.com/docker/go/canonical/json"
/*
A Generic represents a struct that only has a type
*/
type Generic struct {
Type string `json:"type" binding:"required"`
}
/*
MarshalJson returns the canonical json of the generic object
*/
func (g *Generic) MarshalJson() ([]byte, error) {
return json.MarshalCanonical(g)
}
/*
BuildPeerRequest creates a new generic object with type "getpeers"
*/
func (g *Generic) BuildPeerRequest() {
g.Type = "getpeers"
}
/*
BuildChainTipRequest creates a new generic object with type "getchaintip"
*/
func (g *Generic) BuildChainTipRequest() {
g.Type = "getchaintip"
}
/*
BuildMempoolRequest creates a new generic object with type "getmempool"
*/
func (g *Generic) BuildMempoolRequest() {
g.Type = "getmempool"
}