router

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package router provides the routing and entry point for the go-dvote API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildReply

func BuildReply(response transports.MessageAPI, request RouterRequest) transports.Message

BuildReply builds a response message (set ID, Timestamp and Signature)

Types

type HexBytes

type HexBytes []byte

HexBytes is a []byte which encodes as hexadecimal in json, as opposed to the base64 default.

func (HexBytes) MarshalJSON

func (b HexBytes) MarshalJSON() ([]byte, error)

func (*HexBytes) UnmarshalJSON

func (b *HexBytes) UnmarshalJSON(data []byte) error

type RequestMessage

type RequestMessage struct {
	MessageAPI json.RawMessage `json:"request"`

	ID        string   `json:"id"`
	Signature HexBytes `json:"signature"`
}

type ResponseMessage

type ResponseMessage struct {
	MessageAPI json.RawMessage `json:"response"`

	ID        string   `json:"id"`
	Signature HexBytes `json:"signature"`
}

type Router

type Router struct {
	Transports map[string]transports.Transport
	// contains filtered or unexported fields
}

Router holds a router object

func NewRouter

func NewRouter(inbound <-chan transports.Message, transports map[string]transports.Transport,
	signer *ethereum.SignKeys, messageTypeFunc func() transports.MessageAPI) *Router

NewRouter creates a router multiplexer instance

func (*Router) AddAuthKey

func (r *Router) AddAuthKey(addr ethcommon.Address)

AddAuthKey adds a new pubkey address that will have access to private methods

func (*Router) AddHandler

func (r *Router) AddHandler(method, namespace string, handler func(RouterRequest), private, skipSignature bool) error

AddHandler adds a new function handler for serving a specific method identified by name.

func (*Router) DelAuthKey

func (r *Router) DelAuthKey(addr ethcommon.Address)

DelAuthKey deletes a pubkey address from the authorized list

func (*Router) Route

func (r *Router) Route()

Route routes requests through the Router object

func (*Router) SendError

func (r *Router) SendError(request RouterRequest, errMsg string)

SendError formats and sends an error message

type RouterRequest

type RouterRequest struct {
	transports.MessageContext
	Message            transports.MessageAPI
	Method             string
	Id                 string
	Authenticated      bool
	Address            ethcommon.Address
	SignaturePublicKey []byte
	Private            bool
	Signer             *ethereum.SignKeys
}

Jump to

Keyboard shortcuts

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