http

package
v1.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PATH = "path"
)

Variables

This section is empty.

Functions

func Alert400

func Alert400(c *gin.Context, code Code, message string)

Alert400 客户端请求错误

func Alert400WithoutMessage

func Alert400WithoutMessage(c *gin.Context, code Code)

Alert400WithoutMessage 客户端请求错误 不传具体信息

func Alert404Route

func Alert404Route(router *gin.Engine)

Alert404Route 路由不存在

func Alert500

func Alert500(c *gin.Context, code Code, message string)

Alert500 系统错误

func Alert500WithoutMessage

func Alert500WithoutMessage(c *gin.Context, code Code)

Alert500WithoutMessage 系统错误 不传具体信息

func Fail

func Fail(c *gin.Context, err error)

Fail 请求失败

func Parse

func Parse[T any](c *gin.Context, obj *T) (err error)

Parse is a function that parses request parameters into the provided struct

func StatusText

func StatusText(code Code) string

func Success

func Success(c *gin.Context)

Success 请求成功

func SuccessWithData

func SuccessWithData(c *gin.Context, data any)

SuccessWithData 请求成功,返回结果

Types

type Code

type Code uint
const (
	StatusOK Code = 200
	Failure  Code = 1
)
const (
	StatusBadRequest Code = iota + 400000
	MissUserAgent
	StatusNotFound
)
const (
	StatusInternalServerError Code = iota + 500000
)
const (
	StatusMultipleChoices Code = iota + 300000
)

type RequestType

type RequestType[T any] struct {
	// contains filtered or unexported fields
}

RequestType is a generic struct that holds the parsed request data

func NewRequestType

func NewRequestType[T any](data T) RequestType[T]

NewRequestType is a constructor function for RequestType

func (RequestType[T]) Data

func (r RequestType[T]) Data() T

Data returns the parsed request data

Jump to

Keyboard shortcuts

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