httputil

package
v0.0.0-...-5800fbf Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent = "AdsBot-Google (+http://www.google.com/adsbot.html)"
)

Variables

This section is empty.

Functions

func DoRequest

func DoRequest(client *http.Client, req *http.Request) (resp *http.Response, body string, err error)

func DoRequestBytes

func DoRequestBytes(client *http.Client, req *http.Request) (resp *http.Response, body []byte, err error)

func DoRequestJsonDecode

func DoRequestJsonDecode(client *http.Client, req *http.Request, res interface{}) (resp *http.Response, err error)

func EncodeURIComponent

func EncodeURIComponent(str string) string

EncodeURIComponent URLEncode

func Get

func Get(uri string) ([]byte, error)

Get 拉取网页内容

func GetWithJsonDecode

func GetWithJsonDecode(uri string, v interface{}) error

func MakeCommonRequest

func MakeCommonRequest(method string, uri string, contentType ContentType, body []byte) *http.Request

func MakeCommonRequestJson

func MakeCommonRequestJson(method string, uri string, data interface{}) *http.Request

func MakeCommonRequestWithUserAgent

func MakeCommonRequestWithUserAgent(method string, uri string, contentType ContentType, userAgent string, body []byte) *http.Request

func PostForm

func PostForm(uri string, postData url.Values) ([]byte, error)

PostForm 提交FORM类型表单

func PostFormJsonDecode

func PostFormJsonDecode(uri string, postData url.Values, v interface{}) error

func PostJsonWithJsonDecode

func PostJsonWithJsonDecode(uri string, data interface{}, out interface{}) (err error)

PostJsonWithJsonDecode 发送HTTP请求输入输出参数都是json对象

Types

type ContentType

type ContentType string
const (
	ContentTypeJson ContentType = "application/json; charset=utf-8"
	ContentTypeAll  ContentType = "*/*; charset=utf-8"
)

Jump to

Keyboard shortcuts

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