http

package
v0.0.0-...-a5eb945 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOrderIDLength = errors.New("invalid order id length")
View Source
var ErrInvalidSignatureLength = errors.New("invalid signature length")

Functions

func GetBalancesHandler

func GetBalancesHandler(adapter BoxHTTPAdapter) http.HandlerFunc

func GetStatusHandler

func GetStatusHandler(adapter BoxHTTPAdapter) http.HandlerFunc

func MarshalBoxInfo

func MarshalBoxInfo(boxInfo BoxInfo) ([]byte, error)

func MarshalOrderID

func MarshalOrderID(orderIDIn [32]byte) string

func MarshalSignature

func MarshalSignature(signatureIn [65]byte) string

func NewServer

func NewServer(adapter BoxHTTPAdapter) http.Handler

NewServer creates a new http handler

func PostOrdersHandler

func PostOrdersHandler(boxHTTPAdapter BoxHTTPAdapter) http.HandlerFunc

PostOrdersHandler handles post orders request, it gets the signed order id, checks whether the signer is authorized, if the signer is authorized this function adds the order id to the queue.

func RecoveryHandler

func RecoveryHandler(h http.Handler) http.Handler

RecoveryHandler handles errors while processing the requests and populates the errors in the response

func UnmarshalOrderID

func UnmarshalOrderID(orderIDIn string) ([32]byte, error)

func UnmarshalSignature

func UnmarshalSignature(signatureIn string) ([65]byte, error)

func WhoAmIHandler

func WhoAmIHandler(adapter BoxHTTPAdapter) http.HandlerFunc

WhoAmIHandler handles the get whoami request,it gets a challenge from the caller signs it and sends back the signed challenge with it's version information.

Types

type Balance

type Balance struct {
	Address      string `json:"address"`
	Amount       uint64 `json:"amount"`
	PriorityCode uint32 `json:"priorityCode"`
}

type Balances

type Balances []Balance

type BoxHTTPAdapter

type BoxHTTPAdapter interface {
	WhoAmI(challenge string) (WhoAmI, error)
	PostOrder(order PostOrder) (PostOrder, error)
	GetStatus(orderID string) (Status, error)
	GetBalances() (Balances, error)
}

func NewBoxHttpAdapter

func NewBoxHttpAdapter(config config.Config, network network.Config, keystr keystore.Keystore, watcher watch.Watch) BoxHTTPAdapter

type BoxInfo

type BoxInfo struct {
	Challenge           string   `json:"challenge"`
	Version             string   `json:"version"`
	AuthorizedAddresses []string `json:"authorizedAddresses"`
	SupportedCurrencies []string `json:"supportedCurrencies"`
}

func UnmarshalBoxInfo

func UnmarshalBoxInfo(boxInfo []byte) (BoxInfo, error)

type PostOrder

type PostOrder struct {
	OrderID   string `json:"orderID"`
	Signature string `json:"signature"`
}

type Status

type Status struct {
	OrderID string `json:"orderID"`
	Status  string `json:"status"`
}

type WhoAmI

type WhoAmI struct {
	BoxInfo   BoxInfo `json:"boxInfo"`
	Signature string  `json:"signature"`
}

Jump to

Keyboard shortcuts

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