minireq

package module
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: GPL-3.0 Imports: 17 Imported by: 1

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

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

func NewClient

func NewClient() *HttpClient

func (*HttpClient) Connect added in v2.0.8

func (h *HttpClient) Connect(url string, opts ...interface{}) (*MiniResponse, error)

func (*HttpClient) Delete

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

func (*HttpClient) Get

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

func (*HttpClient) Head added in v2.0.8

func (h *HttpClient) Head(url string, opts ...interface{}) (*MiniResponse, error)

func (*HttpClient) Options added in v2.0.8

func (h *HttpClient) Options(url string, opts ...interface{}) (*MiniResponse, error)

func (*HttpClient) Patch

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

func (*HttpClient) Post

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

func (*HttpClient) Put

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

func (*HttpClient) Request

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

Request Universal client

func (*HttpClient) Trace added in v2.0.8

func (h *HttpClient) Trace(url string, opts ...interface{}) (*MiniResponse, error)

type JSONData

type JSONData map[string]interface{}

JSONData Use application/json

type MiniResponse added in v2.0.7

type MiniResponse struct {
	Request  *http.Request
	Response *http.Response
}

func (*MiniResponse) RawData added in v2.0.7

func (res *MiniResponse) RawData() ([]byte, error)

RawData bytes data

func (*MiniResponse) RawJSON added in v2.0.7

func (res *MiniResponse) RawJSON() (interface{}, error)

RawJSON JSON data

func (*MiniResponse) RawNumJSON added in v2.0.7

func (res *MiniResponse) RawNumJSON() (interface{}, error)

RawNumJSON JSON data with real number

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