rest

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 22 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 APIServer

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

APIServer 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,
) (*APIServer, 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 (*APIServer) AuthMiddleware

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

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

func (*APIServer) Run

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

Run runs the rest api server.

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) GetFilteredQuotes

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

GetFilteredQuotes retrieves filtered quotes from the database. GET /quotes?destChainId=&destTokenAddr=&destAmount=.

func (*Handler) GetQuotes

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

GetQuotes retrieves all quotes from the database. GET /quotes. nolint: cyclop

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.

Jump to

Keyboard shortcuts

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