mux

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChaincodeFunction is returned when a chaincode function has already been defined in the router.
	ErrChaincodeFunction = errors.New("chaincode function already defined")

	// ErrUnsupportedMethod is returned when a method is not supported by the router.
	ErrUnsupportedMethod = errors.New("unsupported method")
)

Functions

This section is empty.

Types

type Router

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

Router is a multiplexer that routes methods to the appropriate handler.

func NewRouter

func NewRouter(router ...routing.Router) (*Router, error)

NewRouter creates a new Router with the provided routing.Router instances. It returns an error if any chaincode function is defined more than once.

func (*Router) ArgCount

func (r *Router) ArgCount(method string) int

ArgCount returns the number of arguments the method takes (excluding the receiver).

func (*Router) AuthRequired

func (r *Router) AuthRequired(method string) bool

AuthRequired indicates if the method requires authentication.

func (*Router) Check

func (r *Router) Check(stub shim.ChaincodeStubInterface, method string, args ...string) error

Check validates the provided arguments for the specified method.

func (*Router) Function

func (r *Router) Function(method string) string

Function returns the name of the chaincode function by the specified method.

func (*Router) Handlers

func (r *Router) Handlers() map[string]string

Handlers returns a map of method names to chaincode functions.

func (*Router) Invoke

func (r *Router) Invoke(stub shim.ChaincodeStubInterface, method string, args ...string) ([]byte, error)

Invoke calls the specified method with the provided arguments.

func (*Router) IsInvoke

func (r *Router) IsInvoke(method string) bool

IsInvoke checks if the method is an invoke type.

func (*Router) IsQuery

func (r *Router) IsQuery(method string) bool

IsQuery checks if the method is a query type.

func (*Router) IsTransaction

func (r *Router) IsTransaction(method string) bool

IsTransaction checks if the method is a transaction type.

func (*Router) Method

func (r *Router) Method(function string) string

Method retrieves the method associated with the specified chaincode function.

Jump to

Keyboard shortcuts

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