You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
typeUserRequeststruct {IDint`json:"id"`}func (req*UserRequest)Valid()error {// Valid will be called when decode, if set validate to trueifreq.ID<=0 {returnfmt.Errorf("invalid id")}returnnil}typeUserResponsestruct {IDint`json:"id"`Usernamestring`json:"username"`}http.Handle("/user.get",m.Handler(func(ctx context.Context,req*UserRequest) (*UserResponse,error) {return&UserResponse{ID:1,Username:"acoshift"},nil}))// or use non-ptr structhttp.Handle("/user.get2",m.Handler(func(ctx context.Context,reqUserRequest) (resUserResponse,errerror) {res.ID=1res.Username="acoshift"return}))