api

package
v0.2.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BadRequestErrorHandler = func(c *gin.Context, err error) {
		writeError(c.Writer, err.Error(), http.StatusBadRequest)
	}
	InternalErrorHandler = func(c *gin.Context) {
		writeError(c.Writer, "An unexpected error occurred.", http.StatusInternalServerError)
	}
	UnauthorizedErrorHandler = func(c *gin.Context, err error) {
		writeError(c.Writer, err.Error(), http.StatusUnauthorized)
	}
)

Functions

func GetChainId

func GetChainId(c *gin.Context) (*big.Int, error)

Types

type Error

type Error struct {
	// @Description HTTP status code
	Code int `json:"code"`
	// @Description Error message
	Message string `json:"message"`
	// @Description Support ID for tracking the error
	SupportId string `json:"support_id"`
}

Error represents an API error response @Description Error represents an API error response

type Meta

type Meta struct {
	// @Description Chain ID of the blockchain
	ChainId uint64 `json:"chain_id"`
	// @Description Contract address
	ContractAddress string `json:"address"`
	// @Description Function or event signature
	Signature string `json:"signature"`
	// @Description Current page number
	Page int `json:"page"`
	// @Description Number of items per page
	Limit int `json:"limit"`
	// @Description Total number of items
	TotalItems int `json:"total_items"`
	// @Description Total number of pages
	TotalPages int `json:"total_pages"`
}

Meta represents metadata for a query response @Description Meta represents metadata for a query response

type QueryParams

type QueryParams struct {
	// @Description Map of filter parameters
	FilterParams map[string]string `schema:"-"`
	// @Description Field to group results by
	GroupBy []string `schema:"group_by"`
	// @Description Field to sort results by
	SortBy string `schema:"sort_by"`
	// @Description Sort order (asc or desc)
	SortOrder string `schema:"sort_order"`
	// @Description Page number for pagination
	Page int `schema:"page"`
	// @Description Number of items per page
	Limit int `schema:"limit"`
	// @Description List of aggregate functions to apply
	Aggregates []string `schema:"aggregate"`
}

QueryParams represents the parameters for querying data @Description QueryParams represents the parameters for querying data

func ParseQueryParams

func ParseQueryParams(r *http.Request) (QueryParams, error)

type QueryResponse

type QueryResponse struct {
	// @Description Metadata for the query response
	Meta Meta `json:"meta"`
	// @Description Query result data
	Data interface{} `json:"data,omitempty"`
	// @Description Aggregation results
	Aggregations []map[string]interface{} `json:"aggregations,omitempty"`
}

QueryResponse represents the response structure for a query @Description QueryResponse represents the response structure for a query

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL