curl

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// method
	Get    MethodType = "GET"
	Post   MethodType = "POST"
	Put    MethodType = "PUT"
	Patch  MethodType = "PATCH"
	Delete MethodType = "DELETE"

	// content_type
	JsonType  ContentType = "application/json"
	FormType  ContentType = "application/x-www-form-urlencoded"
	OtherType ContentType = "null" // need set header and body

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client struct

func NewClient

func NewClient(host string) *Client

NewClient new client instance

func (*Client) Curl

func (c *Client) Curl(path string, method MethodType, data interface{}, cType ContentType) ([]byte, error)

Curl url request

func (*Client) Delete

func (c *Client) Delete(path string, data interface{}) ([]byte, error)

Delete request delete, content_type for "application/json"

func (*Client) Get

func (c *Client) Get(path string, data interface{}) ([]byte, error)

Get request get, content_type for "application/json"

func (*Client) Patch

func (c *Client) Patch(path string, data interface{}) ([]byte, error)

Patch request patch, content_type for "application/json"

func (*Client) PatchByForm

func (c *Client) PatchByForm(path string, data interface{}) ([]byte, error)

PatchByForm request patch, content_type for "application/x-www-form-urlencoded"

func (*Client) Post

func (c *Client) Post(path string, data interface{}) ([]byte, error)

Post request post, content_type for "application/json"

func (*Client) PostByForm

func (c *Client) PostByForm(path string, data interface{}) ([]byte, error)

PostByForm request post, content_type for "application/x-www-form-urlencoded"

func (*Client) Put

func (c *Client) Put(path string, data interface{}) ([]byte, error)

Put request put, content_type for "application/json"

func (*Client) PutByForm

func (c *Client) PutByForm(path string, data interface{}) ([]byte, error)

PutByForm request put, content_type for "application/x-www-form-urlencoded"

func (*Client) SetBody

func (c *Client) SetBody(body string) *Client

SetBody set request body

func (*Client) SetCookies

func (c *Client) SetCookies(cookies []*http.Cookie) *Client

SetCookies set request cookies

func (*Client) SetHeaders

func (c *Client) SetHeaders(headers map[string]string) *Client

SetHeaders set request headers

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration) *Client

SetTimeout set request timeout

type ContentType

type ContentType string

type MethodType

type MethodType string

request method

Jump to

Keyboard shortcuts

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