easyurl

package
v0.0.0-...-212a885 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

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

func JSON

func JSON(uri string, Any any) (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 Option

type Option func(*Options)

选项函数

func WithBody

func WithBody(body []byte) Option

WithBody

func WithDecodeGBK

func WithDecodeGBK() Option

*

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

func WithJSON

func WithJSON(v any) Option

func WithPost

func WithPost() Option

func WithTimeout

func WithTimeout(timeout int64) Option

WithTimeout ms

type Options

type Options struct {
	Header  [][]string
	Body    []byte
	Method  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