cgHttp

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AddRouter

func AddRouter(f _configFunc)

添加路由包

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

跨域处理

func ErrHandlerMiddleware

func ErrHandlerMiddleware(retError func(c *gin.Context, err *Error)) gin.HandlerFunc

错误处理中间件

func HandleNotFound

func HandleNotFound(c *gin.Context)

502, 404处理

func InstallRouters

func InstallRouters(e *gin.RouterGroup)

安装已经添加的路由包

func LogHandler

func LogHandler(params *LogHandlerParams) gin.HandlerFunc

Types

type Error

type Error struct {
	StatusCode int    `json:"-"`
	Code       int    `json:"code"`
	Msg        string `json:"message"`
}

func NewError

func NewError(statusCode int, code int, msg string) *Error

func NewErrorWithStatusCode

func NewErrorWithStatusCode(statusCode int, msg string) *Error

func OtherError

func OtherError(message string) *Error

func (*Error) Error

func (e *Error) Error() string

type HttpClient

type HttpClient struct {
	Timeout time.Duration
}

* struct * Description: HttpClient

func (*HttpClient) Get

func (c *HttpClient) Get(url string) *HttpResponse

func (*HttpClient) Post

func (c *HttpClient) Post(postParams *PostParams) *HttpResponse

type HttpResponse

type HttpResponse struct {
	StatusCode int
	BodyString string
	BodyBytes  []byte
	Response   *http.Response
	Err        error
}

* struct * Description: http操作返回对象

type LogHandlerParams

type LogHandlerParams struct {
	MaxBodyLogLength int
	Logger           *log.Logger
}

type PostParams

type PostParams struct {
	Url         string
	Body        interface{}
	ContentType *string
	Headers     map[string]string
}

Jump to

Keyboard shortcuts

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