resty

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) *resty.Client
Example
package main

import (
	"fmt"

	"github.com/omalloc/contrib/kratos/resty"
)

type TestAnythingBody struct {
	Args struct {
		Example string `json:"example,omitempty"`
	} `json:"args"`
	Headers map[string]string `json:"headers"`
}

func main() {
	client := resty.New()

	var body TestAnythingBody
	resp, err := client.NewRequest().SetResult(&body).Get("https://httpbin.org/anything?example=new")
	if err != nil {
		panic(err)
	}

	fmt.Printf("%d-%s", resp.StatusCode(), body.Args.Example)
}
Output:

200-new

Types

type ClientOption

type ClientOption struct {
	// contains filtered or unexported fields
}

ClientOption 自定义属性

type Option

type Option func(*ClientOption)

func WithDebug

func WithDebug(debug bool) Option

func WithPropagators

func WithPropagators(propagators propagation.TextMapPropagator) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithTracer

func WithTracer(tracer trace.Tracer) Option

func WithTransport

func WithTransport(transport *http.Transport) Option

type TracerTransport

type TracerTransport struct {
	*http.Transport
	// contains filtered or unexported fields
}

TracerTransport 自定义 http-transport

func (*TracerTransport) RoundTrip

func (r *TracerTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL