http

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreated = http.StatusCreated
)

Variables

This section is empty.

Functions

func NewCustomHttpClient

func NewCustomHttpClient(opts ...TransportOpt) *http.Client

func NewCustomTransport

func NewCustomTransport(opts ...TransportOpt) http.RoundTripper

Types

type Client

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

func NewClient

func NewClient(opts ...Opt) *Client

func (*Client) Get

func (c *Client) Get(ctx context.Context, address string, data map[string]any) ([]byte, int, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, address string, data map[string]any) ([]byte, int, error)

func (*Client) Put

func (c *Client) Put(ctx context.Context, address string, data map[string]any) ([]byte, int, error)

type CustomTransport

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

func (*CustomTransport) RoundTrip

func (c *CustomTransport) RoundTrip(req *http.Request) (*http.Response, error)

type HandlerFunc

type HandlerFunc func(*gin.Engine)

type Opt

type Opt func(c *Client)

func SetBasicAuth

func SetBasicAuth(username, password string) Opt

func SetContentType

func SetContentType(contentType string) Opt

func SetHttpClient

func SetHttpClient(client *http.Client) Opt

func SetTimeout

func SetTimeout(timeout time.Duration) Opt

SetTimeout The request timeout ,Not client timeout The lifecycle is within one request, not throughout the entire client

type Server

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

func NewHttp

func NewHttp(serverName, address string, port int, handlerFunc HandlerFunc) *Server

NewHttp 构造函数

func (*Server) ServiceInstance

func (s *Server) ServiceInstance() *register.ServiceInstance

ServiceInstance 获取服务实例(服务注册与发现)

func (*Server) Start

func (s *Server) Start() error

Start 开始启动服务

func (*Server) Stop

func (s *Server) Stop() error

Stop 停止服务

type TransportOpt

type TransportOpt func(c *CustomTransport)

func Handle

func Handle(handle func(req *http.Request, requestBytes, responseBytes []byte, err error)) TransportOpt

func Logger

func Logger(logger io.Writer) TransportOpt

func Name

func Name(name string) TransportOpt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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