Documentation ¶
Overview ¶
Package argsmw is a chaincode argument parser and validator middleware
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Arguments ¶
func Arguments(defs ...Definition) rocha.Middleware
Arguments middleware is a argument parsing middleware which receives a set of argument definitions use them to parse the chaincode arguments. The parsed argument will be stored in their respective definition keys
Types ¶
type Definition ¶
Definition is a function which parses a chaincode argument at a given position and stores it's parsed value in a context key, if valid. Else, returns a error which will be returned to the Arguments middleware for further processing
func Int ¶
func Int(key string, base int) Definition
Int is a integer parses which stores a integer in the given context key. It also receives a base parameter which defines which base should be used when decoding the integer
func JSON ¶
func JSON(key string, model interface{}) Definition
JSON is a JSON parser which receives a base structure and parses a argument according to it's format.
r.Handler(handler, argsmw.Arguments(argsmw.JSON("value", &Request{})))
And, in the handler:
func handler(c rocha.Context) pb.Response { request := c.Value("value").(*Request) ... }
func String ¶
func String(key string) Definition
String is a string parser which stores the string argument in a given context key