minireq

package module
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

README

minireq

Simple HTTP Client.

Feature

  • Socks5 Proxy
  • HTTP Basic Auth
  • Params
  • JSON
  • Form
  • Upload File
  • Raw Response
  • JSON Response
  • Cookies

Example

client := NewClient()
params := Params{"foo": "bar"}
res, _ := client.Get("https://postman-echo.com/get", params)
data, _ := res.RawJSON()
fmt.Println(data)

Documentation

Index

Constants

View Source
const DefaultUA = "MiniRequest/" + DefaultVer

DefaultUA Default User-Agent

View Source
const DefaultVer = "2.0.0"

DefaultVer Library version

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth []string

Auth Set HTTP Basic Auth

type Cookies

type Cookies []*http.Cookie

Cookies Set Cookies

type FormData

type FormData struct {
	Values map[string]string
	Files  map[string]string
}

FormData Use multipart/form-data

type FormKV

type FormKV map[string]string

FormData Use application/x-www-from-urlencoded

type Headers

type Headers map[string]string

Headers Set Header

type HttpClient added in v2.0.1

type HttpClient struct {
	Method        string // Request Method
	NoRedirect    bool   // Turn off automatic redirection
	Socks5Address string // Set socks5 proxy
	Timeout       int    // Request timeout
}

func NewClient

func NewClient() *HttpClient

func (*HttpClient) Delete added in v2.0.1

func (h *HttpClient) Delete(url string, opts ...interface{}) (*miniResponse, error)

func (*HttpClient) Get added in v2.0.1

func (h *HttpClient) Get(url string, opts ...interface{}) (*miniResponse, error)

func (*HttpClient) Patch added in v2.0.1

func (h *HttpClient) Patch(url string, opts ...interface{}) (*miniResponse, error)

func (*HttpClient) Post added in v2.0.1

func (h *HttpClient) Post(url string, opts ...interface{}) (*miniResponse, error)

func (*HttpClient) Put added in v2.0.1

func (h *HttpClient) Put(url string, opts ...interface{}) (*miniResponse, error)

func (*HttpClient) Request added in v2.0.1

func (h *HttpClient) Request(url string, opts ...interface{}) (*miniResponse, error)

Request Universal client

type JSONData

type JSONData map[string]interface{}

JSONData Use application/json

type Params

type Params map[string]string

Params Set Params

Jump to

Keyboard shortcuts

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