Documentation
¶
Index ¶
- Variables
- func AddMetaKvs(c *gin.Context, kvs ...string)
- func Download(c *gin.Context, mimeType MimeType, filename string, content []byte) error
- func Error(c *gin.Context, code int, msg string)
- func Failure(c *gin.Context, err error)
- func Forbidden(c *gin.Context, err error)
- func GetAuthorizationToken(c *gin.Context) (string, error)
- func GetMetaKvs(c *gin.Context) []string
- func GetRealIP(c *gin.Context) string
- func InvalidRequest(c *gin.Context, err error)
- func IsPrivateIp(ipStr string) bool
- func NewGinModule(moduleObject any, app string, functions map[string]gin.HandlerFunc) error
- func PermanentRedirect(c *gin.Context, location string)
- func Redirect(c *gin.Context, location string)
- func Success(c *gin.Context, args ...interface{})
- func SuccessPages(c *gin.Context, total int64, pages interface{})
- func SuccessRaw(c *gin.Context, result interface{})
- func Unauthorized(c *gin.Context, err error)
- type GinModule
- type MimeType
- type Module
- type ModuleInfo
- type Option
- type PageResponse
- type Response
- type Route
- type RouterGroup
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenNotFound = errors.New("token not found") ErrInvalidHttpAuthorizationHeader = errors.New("invalid http authorization header") )
View Source
var (
HttpContentTypes = map[MimeType]string{
MimeTypeBinary: "application/octet-stream",
MimeTypePDF: "application/pdf",
MimeTypeMSWord: "application/msword",
MimeTypeJPEG: "image/jpeg",
}
)
Functions ¶
func GetAuthorizationToken ¶
GetAuthorizationToken get bearer token or other token from http header
func InvalidRequest ¶
func NewGinModule ¶
func PermanentRedirect ¶
func Success ¶
Success respond with data empty args respond with 'ok' message args[0] is the response data
func SuccessPages ¶
SuccessPages respond with pagination data
func SuccessRaw ¶
SuccessRaw respond with raw data
func Unauthorized ¶
Types ¶
type GinModule ¶
type GinModule interface {
Module
RegisterHandlers(functions map[string]gin.HandlerFunc) error // 注册Handlers
GetHandlers() map[string]gin.HandlerFunc // 获取handlers
}
func GetModules ¶
func GetModules() []GinModule
type MimeType ¶
type MimeType int
const ( MimeTypeBinary MimeType MimeTypeJPEG MimeTypePDF MimeTypeMSWord )
type Module ¶
type Module interface {
GetApp() string
GetInfo() *ModuleInfo
}
type ModuleInfo ¶
func ParseModuleInfo ¶
func ParseModuleInfo(pkgPath, moduleName string) (*ModuleInfo, error)
ParseModuleInfo 合法的包路径可能为以下格式: * /path/to/v1 * /path/to/v1/pc * /path/to/v2/wxmp
type Option ¶
type Option func(s *baseServer)
func WithProviders ¶
type PageResponse ¶
type RouterGroup ¶
type RouterGroup struct {
UrlPrefix string
// contains filtered or unexported fields
}
func (*RouterGroup) AddRoute ¶
func (rg *RouterGroup) AddRoute(routes ...*Route) error
func (*RouterGroup) Use ¶
func (rg *RouterGroup) Use(middlewares ...gin.HandlerFunc) *RouterGroup
Click to show internal directories.
Click to hide internal directories.