gohttp

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 13 Imported by: 2

README

README

godoc goproxy.cn goreportcard.com deps.dev

go http

go get gitee.com/dtapps/gohttp

import gitee.com/dtapps/gohttp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIp

func ClientIp(r *http.Request) string

ClientIp 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。

func ExternalIp

func ExternalIp() (string, error)

func GetHeadersString

func GetHeadersString(i interface{}) string

func GetRandomUserAgent

func GetRandomUserAgent() string

GetRandomUserAgent 获取用户UA

Types

type Headers

type Headers map[string]interface{}

func NewHeaders

func NewHeaders() Headers

func (Headers) GetQuery

func (p Headers) GetQuery() string

func (Headers) Set

func (p Headers) Set(key string, value interface{})

func (Headers) SetHeaders

func (p Headers) SetHeaders(headers Headers)

type Response

type Response struct {
	Status        string
	StatusCode    int
	Header        http.Header
	Body          []byte
	ContentLength int64
}

func Get

func Get(url string, params map[string]interface{}) (httpResponse Response, err error)

func GetJsonHeader

func GetJsonHeader(url string, params map[string]interface{}, headers Headers) (httpResponse Response, err error)

func PostForm

func PostForm(targetUrl string, params map[string]interface{}) (httpResponse Response, err error)

func PostJson

func PostJson(targetUrl string, paramsStr []byte) (httpResponse Response, err error)

func PostJsonHeader

func PostJsonHeader(targetUrl string, paramsStr []byte, headers Headers) (httpResponse Response, err error)

Jump to

Keyboard shortcuts

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