zhttp

package module
v0.0.0-...-7e27298 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 10 Imported by: 0

README

zhttp

a http repository base on golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorOfEmptyClient = errors.New("client is nil")

Functions

func AddParameterToURL

func AddParameterToURL(URL string, parameter map[string]string) (string, error)

AddParameterToURL 向URL中添加参数

func Client

func Client(timeout time.Duration) *http.Client

Client 创建http client.

func ClientSetCookie

func ClientSetCookie(request *http.Request, data map[string]string)

ClientSetCookie 设置cookie.

func CloseRsp

func CloseRsp(r *http.Response)

CloseRsp 关闭http client的回应.

func CreateToken

func CreateToken(payload map[string]interface{}, key string) (string, error)

CreateToken 创建token

iss: 签发者
sub: 面向的用户
aud: 接收方
exp: 过期时间
nbf: 生效时间
iat: 签发时间
jti: 唯一身份标识

func Get

func Get(client *http.Client, URL string) (*http.Response, error)

Get 发送http get请求.

func GetParameterFromURL

func GetParameterFromURL(URL *url.URL) (url.Values, error)

GetParameterFromURL 获取URL中的参数

func NewRequest

func NewRequest(method string, url string, body []byte) (*http.Request, error)

NewRequest 生成新的请求

func ParseToken

func ParseToken(tokenStr string, key string) (jwt.MapClaims, error)

ParseToken 解析token

func Post

func Post(client *http.Client, url string, contentType string, body []byte) (*http.Response, error)

Post 发送http post请求.

func ServerDelCookie

func ServerDelCookie(rw http.ResponseWriter, name string)

ServerDelCookie 删除cookie.

func ServerGetCookie

func ServerGetCookie(request *http.Request, key string) (string, error)

ServerGetCookie 获取cookie值

func ServerSetCookie

func ServerSetCookie(rw http.ResponseWriter, data map[string]string)

ServerSetCookie 设置cookie.

func SetHeader

func SetHeader(req *http.Request, data map[string]string)

SetHeader 设置请求头.

func TLSClient

func TLSClient(timeout time.Duration, tls *tls.Config) (*http.Client, error)

TLSClient 创建https http client.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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