api

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNil        = NewBusinessError(0, "Success")
	ErrValidation = NewBusinessError(1, "Invalid parameter")
	ErrInternal   = NewBusinessError(2, "Internal server error")
)

General errors

View Source
var ErrHandled = new(BusinessError)

Functions

func MustServe

func MustServe(endpoint string, factory RouteFactory, option ...RouterOption)

func Serve

func Serve(endpoint string, factory RouteFactory, option ...RouterOption) error

func Wrap

func Wrap(controller func(c *gin.Context) (interface{}, error)) gin.HandlerFunc

Types

type BusinessError

type BusinessError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func NewBusinessError

func NewBusinessError(code int, message string) *BusinessError

func NewBusinessErrorWithData

func NewBusinessErrorWithData(code int, message string, data interface{}) *BusinessError

func (*BusinessError) Error

func (err *BusinessError) Error() string

func (*BusinessError) WithData

func (be *BusinessError) WithData(data interface{}) *BusinessError

type RouteFactory

type RouteFactory func(router *gin.Engine)

type RouterOption

type RouterOption struct {
	RecoveryDisabled bool
	LoggerForced     bool
	OriginsAllowed   []string
}

Jump to

Keyboard shortcuts

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