easyurl

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(data string) string

func GET

func GET(uri string, opts ...Option) (data []byte, code int, err error)

func Get

func Get(uri string, options *Options) (data []byte, code int, err error)

func JSON

func JSON(uri string, Any any, options ...Option) (data []byte, code int, err error)

func POST

func POST(uri string, opts ...Option) (data []byte, code int, err error)

func Post

func Post(uri string, options *Options) (data []byte, code int, err error)

func PostForm

func PostForm(uri string, values url.Values, options *Options) (data []byte, code int, err error)

func Request

func Request(uri string, options *Options) (data []byte, code int, err error)

*

  • @description: 默认使用GET方法
  • @param {string} uri
  • @param {*Options} options
  • @return {*}

Types

type BasicAuth

type BasicAuth struct {
	UserName string
	Password string
}

type Opt

type Opt func() Option

type Option

type Option func(*Options)

选项函数

func WithBaicAuth

func WithBaicAuth(user, password string) Option

func WithBody

func WithBody(body []byte) Option

WithBody

func WithDecodeGBK

func WithDecodeGBK() Option

*

  • @description: 增加GBK解码
  • @return {*}

func WithHeader

func WithHeader(key, value string) Option

func WithJSON

func WithJSON(v any) Option

func WithPost

func WithPost() Option

func WithProxy

func WithProxy(proxy string) Option

func WithTimeout

func WithTimeout(timeout int64) Option

WithTimeout ms

type Options

type Options struct {
	*BasicAuth
	Header  [][]string
	Body    []byte
	Method  string
	Proxy   string //代理
	Timeout int64  //ms
	Decode  string //数据是否需要解码
}

func NewDefaultOptions

func NewDefaultOptions() *Options

func NewOptions

func NewOptions(options ...Option) *Options

*

  • @description: 自定义选项
  • @return {*}

func (*Options) AddHeader

func (m *Options) AddHeader(key, value string)

AddHeader 增加header

Jump to

Keyboard shortcuts

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