request

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 12 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 {
}

DefaultRequest 默认请求

func NewDefaultRequest

func NewDefaultRequest() *DefaultRequest

NewDefaultRequest 实例化

func (*DefaultRequest) Get

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

Get HTTP get request

func (*DefaultRequest) Post

func (srv *DefaultRequest) Post(ctx context.Context, url string, data []byte, headMap map[string]string) ([]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, headMap map[string]string) ([]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

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

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, headMap map[string]string) ([]byte, error)
	Post(ctx context.Context, url string, data []byte, headMap map[string]string) ([]byte, error)
	PostJSON(ctx context.Context, url string, data any, headMap map[string]string) ([]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