Skip to content

Commit

Permalink
breadcrumb array support in the constructor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Mar 18, 2024
1 parent 4da510c commit d8d9723
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 5 additions & 4 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,11 @@ func (fi *FuncInfo) Wrap() jrpc2.Handler {
// If fn does not have one of these forms, Check reports an error.
//
// If the type of X is a struct or a pointer to a struct, the generated wrapper
// accepts JSON parameters as either an object or an array. Array parameters
// are mapped to the fields of X in the order of field declaration, save that
// unexported fields are skipped. If a field has a `json:"-"` tag, it is also
// skipped. Anonymous fields are skipped unless they are tagged.
// accepts JSON parameters as either an object or an array. The caller may
// disable array support by calling AllowArray(false). When enabled, array
// parameters are mapped to the fields of X in the order of field declaration,
// save that unexported fields are skipped. If a field has a `json:"-"` tag, it
// is also skipped. Anonymous fields are skipped unless they are tagged.
//
// For other (non-struct) argument types, the accepted format is whatever the
// json.Unmarshal function can decode into the value. Note, however, that the
Expand Down
10 changes: 6 additions & 4 deletions handler/positional.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ func structFieldNames(atype reflect.Type) (bool, []string) {
// // ...
// call := fi.Wrap()
//
// the resulting handler accepts a JSON array with with (exactly) the same
// number of elements as the positional parameters:
// the resulting handler by default accepts a JSON array with with (exactly)
// the same number of elements as the positional parameters:
//
// [17, 23]
//
// No arguments can be omitted in this format, but the caller can use a JSON
// "null" in place of any argument. The handler will also accept a parameter
// object like:
// "null" in place of any argument. The caller may also disable array support
// by setting AllowArray(false) on the resulting FuncInfo.
//
// The handler will also accept a parameter object like:
//
// {"first": 17, "second": 23}
//
Expand Down

0 comments on commit d8d9723

Please sign in to comment.