Documentation ¶
Overview ¶
Package binder is Parameter Binding Verification Plugin for Struct Handler.
Copyright 2018 HenryLee. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const ( TAG_PARAM = "param" // request param tag name TAG_IGNORE_PARAM = "-" // ignore request param tag value KEY_META = "meta" // meta param(optional), value means parameter(optional) KEY_SWAP = "swap" // swap param from the context swap(ctx.Swap()) (optional), value means parameter(optional) KEY_DESC = "desc" // request param description KEY_LEN = "len" // length range of param's value KEY_RANGE = "range" // numerical range of param's value KEY_NONZERO = "nonzero" // param`s value can not be zero KEY_REGEXP = "regexp" // verify the value of the param with a regular expression(param value can not be null) KEY_RERR = "stat" // the custom error code and message for binding or validating )
struct binder parameters'tag
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param use the struct field to define a request parameter model
func (*Param) Description ¶
Description gets the description value for the param
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params struct handler information for binding and validation
type StructArgsBinder ¶
type StructArgsBinder struct {
// contains filtered or unexported fields
}
StructArgsBinder a plugin that binds and validates structure type parameters.
func NewStructArgsBinder ¶
func NewStructArgsBinder(fn ErrorFunc) *StructArgsBinder
NewStructArgsBinder creates a plugin that binds and validates structure type parameters.
func (*StructArgsBinder) Name ¶
func (*StructArgsBinder) Name() string
Name returns the plugin name.
func (*StructArgsBinder) PostReadCallBody ¶
func (s *StructArgsBinder) PostReadCallBody(ctx tp.ReadCtx) *tp.Status
PostReadCallBody binds and validates the registered struct handler.
func (*StructArgsBinder) PostReg ¶
func (s *StructArgsBinder) PostReg(h *tp.Handler) error
PostReg preprocessing struct handler.
func (*StructArgsBinder) SetErrorFunc ¶
func (s *StructArgsBinder) SetErrorFunc(fn ErrorFunc)
SetErrorFunc sets the binding or balidating error function. NOTE: If fn=nil, set as default.