Documentation
¶
Index ¶
- Variables
- func Bytes(s string) ([]byte, error)
- func MessageToValues(msg proto.Message) url.Values
- func Validate(msg proto.Message, opts ...protovalidate.ValidatorOption) error
- func ValuesToMessage(msg proto.Message, values url.Values) error
- type ApiResult
- type ClientOption
- type DemoRequest
- func (*DemoRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DemoRequest) GetFriends() []*User
- func (x *DemoRequest) GetUser() *User
- func (*DemoRequest) ProtoMessage()
- func (x *DemoRequest) ProtoReflect() protoreflect.Message
- func (x *DemoRequest) Reset()
- func (x *DemoRequest) String() string
- type DemoResponse
- type RequestOption
- type Tag
- type User
Constants ¶
This section is empty.
Variables ¶
var ( Tag_name = map[int32]string{ 0: "GO", 1: "RUST", 2: "PHP", 3: "JAVA", } Tag_value = map[string]int32{ "GO": 0, "RUST": 1, "PHP": 2, "JAVA": 3, } )
Enum value maps for Tag.
var File_test_proto protoreflect.FileDescriptor
Functions ¶
func Bytes ¶
Bytes converts the given string representation of a byte sequence into a slice of bytes A bytes sequence is encoded in URL-safe base64 without padding
func MessageToValues ¶
MessageToValues parses proto.Message into url.Values
func Validate ¶
func Validate(msg proto.Message, opts ...protovalidate.ValidatorOption) error
Validate 验证消息体
Types ¶
type ApiResult ¶
type ApiResult[T proto.Message] struct { Code int `json:"code"` Msg string `json:"msg"` Data T `json:"data"` }
ApiResult is the API response with proto.Message
type ClientOption ¶
ClientOption option for resty.Client
func WithRetryAfter ¶
func WithRetryAfter(fn resty.RetryAfterFunc) ClientOption
WithRetryAfter sets a callback to calculate the wait time between retries. Default (nil) implies exponential backoff with jitter
func WithRetryCount ¶
func WithRetryCount(n int) ClientOption
WithRetryCount enables retry on Resty client and allows you to set no. of retry count. Resty uses a Backoff mechanism.
func WithRetryMaxWaitTime ¶
func WithRetryMaxWaitTime(d time.Duration) ClientOption
WithRetryMaxWaitTime sets the max wait time for sleep before retrying request.
Default is 2 seconds.
func WithRetryWaitTime ¶
func WithRetryWaitTime(d time.Duration) ClientOption
WithRetryWaitTime sets the default wait time for sleep before retrying request.
Default is 100 milliseconds.
type DemoRequest ¶
type DemoRequest struct {
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
Friends []*User `protobuf:"bytes,2,rep,name=friends,proto3" json:"friends,omitempty"`
// contains filtered or unexported fields
}
func (*DemoRequest) Descriptor
deprecated
func (*DemoRequest) Descriptor() ([]byte, []int)
Deprecated: Use DemoRequest.ProtoReflect.Descriptor instead.
func (*DemoRequest) GetFriends ¶
func (x *DemoRequest) GetFriends() []*User
func (*DemoRequest) GetUser ¶
func (x *DemoRequest) GetUser() *User
func (*DemoRequest) ProtoMessage ¶
func (*DemoRequest) ProtoMessage()
func (*DemoRequest) ProtoReflect ¶
func (x *DemoRequest) ProtoReflect() protoreflect.Message
func (*DemoRequest) Reset ¶
func (x *DemoRequest) Reset()
func (*DemoRequest) String ¶
func (x *DemoRequest) String() string
type DemoResponse ¶
type DemoResponse struct {
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
// contains filtered or unexported fields
}
func (*DemoResponse) Descriptor
deprecated
func (*DemoResponse) Descriptor() ([]byte, []int)
Deprecated: Use DemoResponse.ProtoReflect.Descriptor instead.
func (*DemoResponse) GetMessage ¶
func (x *DemoResponse) GetMessage() string
func (*DemoResponse) ProtoMessage ¶
func (*DemoResponse) ProtoMessage()
func (*DemoResponse) ProtoReflect ¶
func (x *DemoResponse) ProtoReflect() protoreflect.Message
func (*DemoResponse) Reset ¶
func (x *DemoResponse) Reset()
func (*DemoResponse) String ¶
func (x *DemoResponse) String() string
type RequestOption ¶
RequestOption option for resty.Request
func WithReqDebug ¶
func WithReqDebug(b bool) RequestOption
WithReqDebug enables the debug mode on the current request. It logs the details current request and response.
WithReqDebug(true)
Also, it can be enabled at the request level for a particular request; see [Request.SetDebug].
- For [Request], it logs information such as HTTP verb, Relative URL path, Host, Headers, and Body if it has one.
- For [Response], it logs information such as Status, Response Time, Headers, and Body if it has one.
func WithReqHeader ¶
func WithReqHeader(h http.Header) RequestOption
WithReqHeader sets multiple header fields and their values as a list of strings in the current request.
For Example: To set `Accept` as `text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8`
WithReqHeader(http.Header{
"Accept": []string{"text/html", "application/xhtml+xml", "application/xml;q=0.9", "image/webp", "*/*;q=0.8"},
})
It overrides the header value set at the client instance level.
func WithReqQuery ¶
func WithReqQuery(v url.Values) RequestOption
WithReqQuery appends multiple parameters with multi-value (url.Values) at one go in the current request. It will be formed as query string for the request.
For Example: `status=pending&status=approved&status=open` in the URL after the `?` mark.
WithReqQuery(url.Values{
"status": []string{"pending", "approved", "open"},
})
It overrides the query parameter value set at the client instance level.
func WithReqRetryCondition ¶
func WithReqRetryCondition(fn resty.RetryConditionFunc) RequestOption
WithReqRetryCondition adds a retry condition function to the request's array of functions is checked to determine if the request can be retried. The request will retry if any functions return true and the error is nil.
NOTE: The request level retry conditions are checked before all retry conditions from the client instance.
type Tag ¶
type Tag int32
func (Tag) Descriptor ¶
func (Tag) Descriptor() protoreflect.EnumDescriptor
func (Tag) EnumDescriptor
deprecated
func (Tag) Number ¶
func (x Tag) Number() protoreflect.EnumNumber
func (Tag) Type ¶
func (Tag) Type() protoreflect.EnumType
type User ¶
type User struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Tags []Tag `protobuf:"varint,3,rep,packed,name=tags,proto3,enum=protos.Tag" json:"tags,omitempty"`
Attrs map[string]string `` /* 137-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*User) Descriptor
deprecated
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message