rest

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package rest provides RESTful API services for RFQ

Index

Constants

View Source
const (
	QuoteRoute = "/quotes"
)

QuoteRoute is the API endpoint for handling quote related requests.

Variables

This section is empty.

Functions

func EIP191Auth

func EIP191Auth(c *gin.Context, deadline int64) (accountRecovered common.Address, err error)

EIP191Auth implements ethereum signed message authentication middleware for gin rest api For auth, relayer should pass in eth signed message following eip-191 with the message as the current unix timestamp in seconds i.e. signature (hex encoded) = keccak(bytes.concat("\x19Ethereum Signed Message:\n", len(strconv.Itoa(time.Now().Unix()), strconv.Itoa(time.Now().Unix()))) so that full auth header string: auth = strconv.Itoa(time.Now().Unix()) + ":" + signature see: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the REST API handler.

func NewHandler

func NewHandler(db db.APIDB) *Handler

NewHandler creates a new REST API handler.

func (*Handler) GetQuotes

func (h *Handler) GetQuotes(c *gin.Context)

GetQuotes retrieves all quotes from the database. GET /quotes. nolint: cyclop PingExample godoc @Summary get quotes from all relayers. @Schemes @Param originChainID path int true "origin chain id to filter quotes by" @Param originTokenAddr path string true "origin chain id to filter quotes by" @Param destChainID path int true "destination chain id to filter quotes by" @Param destTokenAddr path string true "destination token address to filter quotes by" @Param relayerAddr path string true "relayer address to filter quotes by" @Description get quotes from all relayers. @Tags quotes @Accept json @Produce json @Success 200 {array} model.GetQuoteResponse @Router /quotes [get].

func (*Handler) ModifyQuote

func (h *Handler) ModifyQuote(c *gin.Context)

ModifyQuote upserts a quote

PUT /quotes @dev Protected Method: Authentication is handled through middleware in server.go. nolint: cyclop @Summary get quotes from all relayers. @Schemes @Description upsert a quote from relayer. @Param request body model.PutQuoteRequest true "query params" @Tags quotes @Accept json @Produce json @Success 200 @Router /quotes [put].

type QuoterAPIServer added in v0.0.15

type QuoterAPIServer struct {
	// contains filtered or unexported fields
}

QuoterAPIServer is a struct that holds the configuration, database connection, gin engine, RPC client, metrics handler, and fast bridge contracts. It is used to initialize and run the API server.

func NewAPI

func NewAPI(
	ctx context.Context,
	cfg config.Config,
	handler metrics.Handler,
	omniRPCClient omniClient.RPCClient,
	store db.APIDB,
) (*QuoterAPIServer, error)

NewAPI holds the configuration, database connection, gin engine, RPC client, metrics handler, and fast bridge contracts. It is used to initialize and run the API server.

func (*QuoterAPIServer) AuthMiddleware added in v0.0.15

func (r *QuoterAPIServer) AuthMiddleware() gin.HandlerFunc

AuthMiddleware is the Gin authentication middleware that authenticates requests using EIP191.

func (*QuoterAPIServer) Run added in v0.0.15

func (r *QuoterAPIServer) Run(ctx context.Context) error

Run runs the quoter api server.

Jump to

Keyboard shortcuts

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