httphelper

package
v0.0.0-...-68b20d9 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommResToSpecial

func CommResToSpecial(in interface{}, out interface{}) error

func DeleteRequest

func DeleteRequest(ctx context.Context, returnValuePointer interface{}, baseUrl string, requestPath string, params url.Values) error

Helper method to make the delete request and return the body

func GetRequest

func GetRequest(ctx context.Context, returnValuePointer interface{}, baseUrl string, requestPath string, requestParams url.Values) error

Helper method to make the get request and return the body

func PostRequest

func PostRequest(
	ctx context.Context,
	returnValuePointer interface{},
	url string,
	data interface{}) error

Helper method to make the post JSON request and return the body

func PutRequest

func PutRequest(
	ctx context.Context,
	returnValuePointer interface{},
	url string,
	data interface{}) error

func RenderFail

func RenderFail(ctx context.Context, err error, w http.ResponseWriter, lc logger.LoggingClient)

func RenderFailNoLog

func RenderFailNoLog(ctx context.Context, err error, w http.ResponseWriter)

func RenderRpcFail

func RenderRpcFail(err error, lc logger.LoggingClient) error

func Result

func Result(code uint32, data interface{}, msg string, w http.ResponseWriter, lc logger.LoggingClient)

func ResultExcelData

func ResultExcelData(c *gin.Context, fileName string, data *bytes.Buffer)

func ResultNoLog

func ResultNoLog(code uint32, data interface{}, msg string, w http.ResponseWriter)

func ResultSuccess

func ResultSuccess(data interface{}, w http.ResponseWriter, lc logger.LoggingClient)

func ResultSuccessNoLog

func ResultSuccessNoLog(data interface{}, w http.ResponseWriter)

func ResultZipFile

func ResultZipFile(c *gin.Context, lc logger.LoggingClient, fileName string, file *os.File)

Types

type CommonResponse

type CommonResponse struct {
	Success    bool        `json:"success"`                     // 接口是否成功
	ErrorCode  uint32      `json:"errorCode"`                   // 错误码
	ErrorMsg   string      `json:"errorMsg,omitempty"`          // 错误信息
	SuccessMsg string      `json:"successMsg,omitempty"`        // 成功信息
	Result     interface{} `json:"result" swaggertype:"object"` // 返回结果
}

func NewFailCommonResponse

func NewFailCommonResponse(err error) CommonResponse

deprecated

func NewFailWithI18nResponse

func NewFailWithI18nResponse(ctx context.Context, err error) CommonResponse

func NewSuccessCommonResponse

func NewSuccessCommonResponse(data interface{}) CommonResponse

func WsResult

func WsResult(code uint32, data interface{}, errMsg string, successMsg string) CommonResponse

func WsResultFail

func WsResultFail(code uint32, msg string) CommonResponse

func (CommonResponse) Error

func (r CommonResponse) Error() error

type ResPageResult

type ResPageResult struct {
	List     interface{} `json:"list"`
	Total    uint32      `json:"total"`
	Page     int         `json:"page"`
	PageSize int         `json:"pageSize"`
}

func NewPageResult

func NewPageResult(responses interface{}, total uint32, page int, pageSize int) ResPageResult

Jump to

Keyboard shortcuts

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