Documentation ¶
Index ¶
- func RespondWith(c *gin.Context, status int, dataField interface{}, errMessage string, ...)
- func RespondWithInternalError(c *gin.Context, err error, innerErr error)
- func RespondWithSuccess(c *gin.Context, data interface{})
- func RespondWithValidationError(c *gin.Context, err error, innerErr error)
- type AdditionalMiddleware
- type ApiFacadeHandler
- type EndpointHandlerData
- type FacadeHandler
- type GenericAPIResponse
- type GroupHandler
- type HttpServerCloser
- type MiddlewarePosition
- type MiddlewareProcessor
- type ReturnCode
- type UpgradeableHttpServerHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RespondWith ¶ added in v1.0.147
func RespondWith(c *gin.Context, status int, dataField interface{}, errMessage string, code ReturnCode)
RespondWith will respond with the generic API response
func RespondWithInternalError ¶ added in v1.3.37
RespondWithInternalError should be called when the request cannot be satisfied due to an internal error
func RespondWithSuccess ¶ added in v1.3.37
RespondWithSuccess should be called when the request can be satisfied
Types ¶
type AdditionalMiddleware ¶ added in v1.2.23
type AdditionalMiddleware struct { Middleware gin.HandlerFunc Position MiddlewarePosition }
AdditionalMiddleware holds the data needed for adding a middleware to an API endpoint
type ApiFacadeHandler ¶ added in v1.2.0
type ApiFacadeHandler interface { RestApiInterface() string RestAPIServerDebugMode() bool PprofEnabled() bool IsInterfaceNil() bool }
ApiFacadeHandler interface defines methods that can be used from `elrondFacade` context variable
type EndpointHandlerData ¶ added in v1.2.23
type EndpointHandlerData struct { Path string Method string Handler gin.HandlerFunc AdditionalMiddlewares []AdditionalMiddleware }
EndpointHandlerData holds the items needed for creating a new gin HTTP endpoint
type FacadeHandler ¶ added in v1.2.23
type FacadeHandler interface { GetBalance(address string, options api.AccountQueryOptions) (*big.Int, api.BlockInfo, error) GetUsername(address string, options api.AccountQueryOptions) (string, api.BlockInfo, error) GetValueForKey(address string, key string, options api.AccountQueryOptions) (string, api.BlockInfo, error) GetAccount(address string, options api.AccountQueryOptions) (api.AccountResponse, api.BlockInfo, error) GetESDTData(address string, key string, nonce uint64, options api.AccountQueryOptions) (*esdt.ESDigitalToken, api.BlockInfo, error) GetESDTsRoles(address string, options api.AccountQueryOptions) (map[string][]string, api.BlockInfo, error) GetNFTTokenIDsRegisteredByAddress(address string, options api.AccountQueryOptions) ([]string, api.BlockInfo, error) GetESDTsWithRole(address string, role string, options api.AccountQueryOptions) ([]string, api.BlockInfo, error) GetAllESDTTokens(address string, options api.AccountQueryOptions) (map[string]*esdt.ESDigitalToken, api.BlockInfo, error) GetKeyValuePairs(address string, options api.AccountQueryOptions) (map[string]string, api.BlockInfo, error) GetBlockByHash(hash string, options api.BlockQueryOptions) (*api.Block, error) GetBlockByNonce(nonce uint64, options api.BlockQueryOptions) (*api.Block, error) GetBlockByRound(round uint64, options api.BlockQueryOptions) (*api.Block, error) GetInternalShardBlockByNonce(format common.ApiOutputFormat, nonce uint64) (interface{}, error) GetInternalShardBlockByHash(format common.ApiOutputFormat, hash string) (interface{}, error) GetInternalShardBlockByRound(format common.ApiOutputFormat, round uint64) (interface{}, error) GetInternalMetaBlockByNonce(format common.ApiOutputFormat, nonce uint64) (interface{}, error) GetInternalMetaBlockByHash(format common.ApiOutputFormat, hash string) (interface{}, error) GetInternalMetaBlockByRound(format common.ApiOutputFormat, round uint64) (interface{}, error) GetInternalStartOfEpochMetaBlock(format common.ApiOutputFormat, epoch uint32) (interface{}, error) GetInternalMiniBlockByHash(format common.ApiOutputFormat, hash string, epoch uint32) (interface{}, error) Trigger(epoch uint32, withEarlyEndOfEpoch bool) error IsSelfTrigger() bool GetTotalStakedValue() (*api.StakeValues, error) GetDirectStakedList() ([]*api.DirectStakedValue, error) GetDelegatorsList() ([]*api.Delegator, error) StatusMetrics() external.StatusMetricsHandler GetTokenSupply(token string) (*api.ESDTSupply, error) GetAllIssuedESDTs(tokenType string) ([]string, error) GetHeartbeats() ([]data.PubKeyHeartbeat, error) GetQueryHandler(name string) (debug.QueryHandler, error) GetPeerInfo(pid string) ([]core.QueryP2PPeerInfo, error) GetProof(rootHash string, address string) (*common.GetProofResponse, error) GetProofDataTrie(rootHash string, address string, key string) (*common.GetProofResponse, *common.GetProofResponse, error) GetProofCurrentRootHash(address string) (*common.GetProofResponse, error) VerifyProof(rootHash string, address string, proof [][]byte) (bool, error) GetThrottlerForEndpoint(endpoint string) (core.Throttler, bool) CreateTransaction(nonce uint64, value string, receiver string, receiverUsername []byte, sender string, senderUsername []byte, gasPrice uint64, gasLimit uint64, data []byte, signatureHex string, chainID string, version uint32, options uint32) (*transaction.Transaction, []byte, error) ValidateTransaction(tx *transaction.Transaction) error ValidateTransactionForSimulation(tx *transaction.Transaction, checkSignature bool) error SendBulkTransactions([]*transaction.Transaction) (uint64, error) SimulateTransactionExecution(tx *transaction.Transaction) (*txSimData.SimulationResults, error) GetTransaction(hash string, withResults bool) (*transaction.ApiTransactionResult, error) ComputeTransactionGasLimit(tx *transaction.Transaction) (*transaction.CostResponse, error) EncodeAddressPubkey(pk []byte) (string, error) ValidatorStatisticsApi() (map[string]*state.ValidatorApiResponse, error) ExecuteSCQuery(*process.SCQuery) (*vm.VMOutputApi, error) DecodeAddressPubkey(pk string) ([]byte, error) RestApiInterface() string RestAPIServerDebugMode() bool PprofEnabled() bool GetGenesisNodesPubKeys() (map[uint32][]string, map[uint32][]string, error) GetGenesisBalances() ([]*common.InitialAccountAPI, error) GetGasConfigs() (map[string]map[string]uint64, error) GetTransactionsPool(fields string) (*common.TransactionsPoolAPIResponse, error) GetTransactionsPoolForSender(sender, fields string) (*common.TransactionsPoolForSenderApiResponse, error) GetLastPoolNonceForSender(sender string) (uint64, error) GetTransactionsPoolNonceGapsForSender(sender string) (*common.TransactionsPoolNonceGapsForSenderApiResponse, error) IsInterfaceNil() bool }
FacadeHandler defines all the methods that a facade should implement
type GenericAPIResponse ¶
type GenericAPIResponse struct { Data interface{} `json:"data"` Error string `json:"error"` Code ReturnCode `json:"code"` }
GenericAPIResponse defines the structure of all responses on API endpoints
type GroupHandler ¶ added in v1.2.23
type GroupHandler interface { UpdateFacade(newFacade interface{}) error RegisterRoutes( ws *gin.RouterGroup, apiConfig config.ApiRoutesConfig, ) IsInterfaceNil() bool }
GroupHandler defines the actions needed to be performed by an gin API group
type HttpServerCloser ¶ added in v1.2.0
HttpServerCloser defines the basic actions of starting and closing that a web server should be able to do
type MiddlewarePosition ¶ added in v1.2.23
type MiddlewarePosition bool
MiddlewarePosition is the type that specifies the position of a middleware relative to the base endpoint handler
const ( // Before indicates that the middleware should be used before the base endpoint handler Before MiddlewarePosition = true // After indicates that the middleware should be used after the base endpoint handler After MiddlewarePosition = false )
type MiddlewareProcessor ¶ added in v1.2.0
type MiddlewareProcessor interface { MiddlewareHandlerFunc() gin.HandlerFunc IsInterfaceNil() bool }
MiddlewareProcessor defines a processor used internally by the web server when processing requests
type ReturnCode ¶
type ReturnCode string
ReturnCode defines the type defines to identify return codes
const ReturnCodeInternalError ReturnCode = "internal_issue"
ReturnCodeInternalError defines a request which hasn't been executed successfully due to an internal error
const ReturnCodeRequestError ReturnCode = "bad_request"
ReturnCodeRequestError defines a request which hasn't been executed successfully due to a bad request received
const ReturnCodeSuccess ReturnCode = "successful"
ReturnCodeSuccess defines a successful request
const ReturnCodeSystemBusy ReturnCode = "system_busy"
ReturnCodeSystemBusy defines a request which hasn't been executed successfully due to too many requests
type UpgradeableHttpServerHandler ¶ added in v1.2.0
type UpgradeableHttpServerHandler interface { StartHttpServer() error UpdateFacade(facade FacadeHandler) error Close() error IsInterfaceNil() bool }
UpgradeableHttpServerHandler defines the actions that an upgradeable http server need to do