http

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: GPL-3.0 Imports: 3 Imported by: 2

README

golang http 请求封装

简介

实现http请求

使用

go get github.com/wms3001/http

实例

  1. get
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token", //url
    "", // username
    "", //password
    m,  //header
    a,  //accept
    "", //body
    10, //timeout
    "", //type
    []byte{}, //file
}
resp := hp.Get()
  1. post
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token",
    "",
    "",
    m,
    a,
    "",
    10,
    "",
    []byte{},
}
resp := hp.Post()
  1. delete
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token",
    "",
    "",
    m,
    a,
    "",
    10,
    "",
    []byte{},
}
resp := hp.Delete()
  1. head
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token",
    "",
    "",
    m,
    a,
    "",
    10,
    "",
    []byte{},
}
resp := hp.Head()
  1. options
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token",
    "",
    "",
    m,
    a,
    "",
    10,
    "",
    []byte{},
}
resp := hp.Options()
  1. put
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token",
    "",
    "",
    m,
    a,
    "",
    10,
    "",
    []byte{},
}
resp := hp.Put()
  1. trace
m := map[string]string{
    "name":    "backy",
    "species": "dog",
}
a := map[string]string{
    "Accept": "application/json",
    //"Accept": "text/plain",
}
hp := Http{
    "https://www.wishpost.cn/api/v3/oauth/access_token",
    "",
    "",
    m,
    a,
    "",
    10,
    "",
    []byte{},
}
resp := hp.Trace()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Http

type Http struct {
	Url           string            `json:"url"`
	BasicAuthUser string            `json:"basicAuthUser"`
	BasicAuthPass string            `json:"basicAuthPass"`
	Header        map[string]string `json:"header"`
	AppendHeader  map[string]string `json:"appendHeader"`
	Body          string            `json:"body"`
	TimeOut       time.Duration     `json:"timeOut"`
	Type          string            `json:"type"`
	SFile         []byte            `json:"sFile"`
}

func (*Http) Delete

func (http *Http) Delete() *goCommon.Resp

func (*Http) Get

func (http *Http) Get() *goCommon.Resp

func (*Http) Head

func (http *Http) Head() *goCommon.Resp

func (*Http) Options

func (http *Http) Options() *goCommon.Resp

func (*Http) Post

func (http *Http) Post() *goCommon.Resp

func (*Http) Put

func (http *Http) Put() *goCommon.Resp

func (*Http) Trace

func (http *Http) Trace() *goCommon.Resp

Jump to

Keyboard shortcuts

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