Documentation ¶
Index ¶
- Constants
- Variables
- func Abort(ctx *gin.Context, data any, err Error)
- func CORS(ctx *gin.Context)
- func Default(group Group) (r *gin.Engine)
- func GetUser[U any](ctx *gin.Context) (u U)
- func NameOfFunction(any) string
- func NameOfHandler(fn HandlerFunc) string
- func New(group Group) (r *gin.Engine)
- func ParsePath(path string) string
- func SetUser(ctx *gin.Context, user any)
- func SplitHandlerName(fn HandlerFunc) (method, path string)
- func Static(s string) gin.HandlerFunc
- type Chain
- type DefaultResponse
- type Error
- type ErrorWithCode
- type Group
- type HandlerFunc
- type Response
Constants ¶
View Source
const ( MethodGet = "Get" MethodHead = "Head" MethodPost = "Post" MethodPut = "Put" MethodPatch = "Patch" // RFC 5789 MethodDelete = "Delete" MethodConnect = "Connect" MethodOptions = "Options" MethodTrace = "Trace" )
View Source
const ( Colon = "Colon" Asterisk = "Asterisk" )
View Source
const UserKey string = "__user__"
Variables ¶
View Source
var AnyMethods = []string{ MethodGet, MethodHead, MethodPost, MethodPut, MethodPatch, MethodDelete, MethodConnect, MethodOptions, MethodTrace, }
View Source
var MethodEXP = regexp.MustCompile("^(" + strings.Join(AnyMethods, "|") + ")(\\w+)")
View Source
var NewResponse = func() Response { return new(DefaultResponse) }
Functions ¶
func NameOfFunction ¶
func NameOfHandler ¶
func NameOfHandler(fn HandlerFunc) string
func SplitHandlerName ¶
func SplitHandlerName(fn HandlerFunc) (method, path string)
func Static ¶
func Static(s string) gin.HandlerFunc
Types ¶
type Chain ¶
type Chain []HandlerFunc
type DefaultResponse ¶
type ErrorWithCode ¶
type ErrorWithCode struct {
// contains filtered or unexported fields
}
func AutoError ¶
func AutoError(err error) (e ErrorWithCode)
func NewError ¶
func NewError(code int, message string) ErrorWithCode
func (ErrorWithCode) Code ¶
func (e ErrorWithCode) Code() int
func (ErrorWithCode) Error ¶
func (e ErrorWithCode) Error() string
func (ErrorWithCode) Format ¶
func (e ErrorWithCode) Format(a ...any) ErrorWithCode
type Group ¶
type HandlerFunc ¶
func (HandlerFunc) Handler ¶
func (f HandlerFunc) Handler(ctx *gin.Context)
Call is a gin.HandlerFunc with receiver f.
Click to show internal directories.
Click to hide internal directories.