request

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package request HTTP request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultRequest

type DefaultRequest struct {
	AccessTokenKey string
}

DefaultRequest 默认请求

func NewDefaultRequest

func NewDefaultRequest(accessTokenKey string) *DefaultRequest

NewDefaultRequest 实例化

func (*DefaultRequest) Get

func (srv *DefaultRequest) Get(ctx context.Context, url string) ([]byte, error)

Get HTTP get request

func (*DefaultRequest) Post

func (srv *DefaultRequest) Post(ctx context.Context, url string, data []byte) ([]byte, error)

Post HTTP post request

func (*DefaultRequest) PostFile

func (srv *DefaultRequest) PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)

PostFile HTTP post file request

func (*DefaultRequest) PostJSON

func (srv *DefaultRequest) PostJSON(ctx context.Context, url string, data any) ([]byte, error)

PostJSON HTTP post JSON request

func (*DefaultRequest) PostJSONWithRespContentType

func (srv *DefaultRequest) PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error)

PostJSONWithRespContentType HTTP post JSON request with the response content type

func (*DefaultRequest) PostMultipartForm

func (srv *DefaultRequest) PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) (resp []byte, err error)

PostMultipartForm HTTP post multipart form request

func (*DefaultRequest) PostXML added in v0.0.3

func (srv *DefaultRequest) PostXML(ctx context.Context, url string, data any) ([]byte, error)

PostXML perform the HTTP/POST request with XML body

func (*DefaultRequest) PostXMLWithTLS added in v0.0.4

func (srv *DefaultRequest) PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error)

PostXMLWithTLS perform the HTTP/POST request with XML body and TLS

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool   `json:"isFile"`
	Value     []byte `json:"value"`
	FieldName string `json:"fieldName"`
	FileName  string `json:"fileName"`
}

MultipartFormField multipart form field

type Request

type Request interface {
	Get(ctx context.Context, url string) ([]byte, error)
	Post(ctx context.Context, url string, data []byte) ([]byte, error)
	PostJSON(ctx context.Context, url string, data any) ([]byte, error)
	PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error)
	PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)
	PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)
	PostXML(ctx context.Context, url string, data any) ([]byte, error)
	PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error)
}

Request HTTP request interface

Jump to

Keyboard shortcuts

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