Documentation ¶
Index ¶
- Variables
- func ExternalIP() net.IP
- func IsValidObjectID(s string) booldeprecated
- func LocalIP() string
- func NewLogger(viper *viper.Viper) *zap.Logger
- func ReadFileFromUrl(url string) ([]byte, error)
- func ReadFileFromUrlAsBase64(url string) (string, error)
- func Recovery(logger *zap.Logger) gin.HandlerFunc
- func RegisterDefaultMiddleware(engine *gin.Engine, systemMiddleware *SystemMiddleware)
- func RenderBadRequestResult(ctx *gin.Context, err error)
- func RenderErrorResult(ctx *gin.Context, status int, err error)
- func RenderForbiddenResult(ctx *gin.Context, err error)
- func RenderInternalServerErrorResult(ctx *gin.Context, err error)
- func RenderNotFoundResult(ctx *gin.Context, err error)
- func RenderResult(ctx *gin.Context, status int, result any)
- func RenderServiceUnavailableResult(ctx *gin.Context, err error)
- func RenderSuccessResult(ctx *gin.Context, result any)
- func RenderUnauthorizedResult(ctx *gin.Context, err error)
- func SyncDB(f func() error) gin.HandlerFunc
- func SystemStats(ctx *gin.Context)
- func Url(baseUrl string, path string, urlValues url.Values) string
- func Version(config *viper.Viper, version string) gin.HandlerFunc
- type Application
- func (m *Application) GetDatabase() *Database
- func (m *Application) GetEngine() *gin.Engine
- func (m *Application) GetLogger() *zap.Logger
- func (m *Application) GetNacos() *Nacos
- func (m *Application) GetRedis() *Redis
- func (m *Application) GetTencentEss() *TencentEss
- func (m *Application) Jobs(scheduler *Scheduler) func(ctx *gin.Context)
- func (m *Application) RegisterScheduler(scheduler *Scheduler)
- func (m *Application) RemoveJobById(scheduler *Scheduler) func(ctx *gin.Context)
- func (m *Application) Run(funcs ...ApplicationFunc)
- func (m *Application) Start(scheduler *Scheduler) func(ctx *gin.Context)
- func (m *Application) StopJobs(scheduler *Scheduler) func(ctx *gin.Context)
- type ApplicationFunc
- type Banlancer
- type BusinessError
- func NewBadRequestBusinessError(message string) *BusinessError
- func NewBusinessError(status int, code string, message string) *BusinessError
- func NewForbiddenBusinessError(message string) *BusinessError
- func NewInternalServerErrorBusinessError(message string) *BusinessError
- func NewNotFoundBusinessError(message string) *BusinessError
- func NewServiceUnavailableBusinessError(message string) *BusinessError
- func NewUnauthorizedBusinessError(message string) *BusinessError
- type Database
- type EncodingFunc
- type IdName
- type Job
- type JsonResult
- type KeyValue
- type Nacos
- func (m *Nacos) BuildDefaultServiceClient(webClient *WebClient) *ServiceClient
- func (m *Nacos) BuildServiceClientWithConfigKey(webClient *WebClient, configKey string) *ServiceClient
- func (m *Nacos) GetConfig() *viper.Viper
- func (m *Nacos) GetDefaultNameingClient() naming_client.INamingClient
- func (m *Nacos) GetMetadata() map[string]string
- func (m *Nacos) GetServiceNamingClient(configKey string) naming_client.INamingClient
- func (m *Nacos) GetServiceNamingClients() map[string]naming_client.INamingClient
- func (m *Nacos) Init()
- type NacosBanlancer
- type ObjectID
- func (id ObjectID) Hex() string
- func (id ObjectID) IsZero() bool
- func (id ObjectID) MarshalJSON() ([]byte, error)
- func (id ObjectID) MarshalText() ([]byte, error)
- func (id ObjectID) String() string
- func (id ObjectID) Timestamp() time.Time
- func (id *ObjectID) UnmarshalJSON(b []byte) error
- func (id *ObjectID) UnmarshalText(b []byte) error
- type PageParam
- type PageResult
- type Redis
- type RequestHeaderFunc
- type RestResult
- func NewBadRequestRestResult(data any, message string) *RestResult
- func NewForbiddenRestResult(data any, message string) *RestResult
- func NewInternalServerErrorRestResult(data any, message string) *RestResult
- func NewNotFoundRestResult(data any, message string) *RestResult
- func NewRestResult(status int, code string, data any, message string) *RestResult
- func NewServiceUnavailableRestResult(data any, message string) *RestResult
- func NewSuccessRestResult(data any, message string) *RestResult
- func NewUnauthorizedRestResult(data any, message string) *RestResult
- type Scheduler
- type ServiceClient
- func (m *ServiceClient) Delete(serviceName string, path string, urlValues url.Values, bodyValue any, ...) (int, []byte, error)
- func (m *ServiceClient) Do(serviceName string, method string, path string, urlValues url.Values, ...) (*http.Response, int, []byte, error)
- func (m *ServiceClient) Get(serviceName string, path string, urlValues url.Values, ...) (int, []byte, error)
- func (m *ServiceClient) Post(serviceName string, path string, urlValues url.Values, bodyValue any, ...) (int, []byte, error)
- func (m *ServiceClient) Put(serviceName string, path string, urlValues url.Values, bodyValue any, ...) (int, []byte, error)
- type SystemMiddleware
- type SystemVersion
- type TencentEss
- type TencentEssClient
- type UpdateLog
- type WebClient
- func (m *WebClient) Delete(baseUrl string, path string, urlValues url.Values, bodyValue any, ...) (int, []byte, error)
- func (m *WebClient) Do(method string, baseUrl string, path string, urlValues url.Values, ...) (*http.Response, int, []byte, error)
- func (m *WebClient) DoRequest(req *http.Request) (*http.Response, int, []byte, error)
- func (m *WebClient) Get(baseUrl string, path string, urlValues url.Values, encodingFunc EncodingFunc, ...) (int, []byte, error)
- func (m *WebClient) Post(baseUrl string, path string, urlValues url.Values, bodyValue any, ...) (int, []byte, error)
- func (m *WebClient) Put(baseUrl string, path string, urlValues url.Values, bodyValue any, ...) (int, []byte, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHex = errors.New("the provided hex string is not a valid ObjectID")
ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.
Functions ¶
func ExternalIP ¶ added in v1.0.3
func IsValidObjectID
deprecated
added in
v1.0.3
func ReadFileFromUrl ¶ added in v1.0.11
func ReadFileFromUrlAsBase64 ¶ added in v1.0.11
func RegisterDefaultMiddleware ¶ added in v1.0.14
func RegisterDefaultMiddleware(engine *gin.Engine, systemMiddleware *SystemMiddleware)
func RenderBadRequestResult ¶ added in v1.1.4
func RenderErrorResult ¶ added in v1.1.6
func RenderForbiddenResult ¶ added in v1.1.4
func RenderInternalServerErrorResult ¶ added in v1.1.4
func RenderNotFoundResult ¶ added in v1.1.4
func RenderServiceUnavailableResult ¶ added in v1.1.4
func RenderSuccessResult ¶ added in v1.1.14
func RenderUnauthorizedResult ¶ added in v1.1.4
func SyncDB ¶ added in v1.0.9
func SyncDB(f func() error) gin.HandlerFunc
func SystemStats ¶ added in v1.0.7
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func NewApplication ¶
func NewApplication( metadata map[string]string, version string, syncDBFunc func() error, ) *Application
func (*Application) GetDatabase ¶ added in v1.1.8
func (m *Application) GetDatabase() *Database
func (*Application) GetEngine ¶
func (m *Application) GetEngine() *gin.Engine
func (*Application) GetLogger ¶ added in v1.1.8
func (m *Application) GetLogger() *zap.Logger
func (*Application) GetNacos ¶ added in v1.1.8
func (m *Application) GetNacos() *Nacos
func (*Application) GetRedis ¶ added in v1.1.8
func (m *Application) GetRedis() *Redis
func (*Application) GetTencentEss ¶ added in v1.1.48
func (m *Application) GetTencentEss() *TencentEss
func (*Application) Jobs ¶ added in v1.1.16
func (m *Application) Jobs(scheduler *Scheduler) func(ctx *gin.Context)
func (*Application) RegisterScheduler ¶ added in v1.1.16
func (m *Application) RegisterScheduler(scheduler *Scheduler)
func (*Application) RemoveJobById ¶ added in v1.1.17
func (m *Application) RemoveJobById(scheduler *Scheduler) func(ctx *gin.Context)
func (*Application) Run ¶
func (m *Application) Run(funcs ...ApplicationFunc)
type ApplicationFunc ¶
type ApplicationFunc func()
type BusinessError ¶ added in v1.0.16
type BusinessError struct { Status int `json:"status"` Code string `json:"code"` Message string `json:"message"` }
func NewBadRequestBusinessError ¶ added in v1.0.17
func NewBadRequestBusinessError(message string) *BusinessError
func NewBusinessError ¶ added in v1.0.17
func NewBusinessError(status int, code string, message string) *BusinessError
func NewForbiddenBusinessError ¶ added in v1.1.4
func NewForbiddenBusinessError(message string) *BusinessError
func NewInternalServerErrorBusinessError ¶ added in v1.0.17
func NewInternalServerErrorBusinessError(message string) *BusinessError
func NewNotFoundBusinessError ¶ added in v1.0.17
func NewNotFoundBusinessError(message string) *BusinessError
func NewServiceUnavailableBusinessError ¶ added in v1.1.4
func NewServiceUnavailableBusinessError(message string) *BusinessError
func NewUnauthorizedBusinessError ¶ added in v1.1.4
func NewUnauthorizedBusinessError(message string) *BusinessError
func (*BusinessError) Error ¶ added in v1.0.16
func (m *BusinessError) Error() string
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewDatabase ¶
func (*Database) GetDatabase ¶ added in v1.1.46
type EncodingFunc ¶ added in v1.0.18
type Job ¶ added in v1.1.11
type JsonResult ¶ added in v1.1.3
type JsonResult struct { Status int BusinessError *BusinessError Text string }
func ResponseToJsonResult ¶ added in v1.1.3
func ResponseToJsonResult(status int, bytes []byte, result ...any) (*JsonResult, error)
type KeyValue ¶ added in v1.1.18
func NewKeyValue ¶ added in v1.1.18
type Nacos ¶
type Nacos struct {
// contains filtered or unexported fields
}
func (*Nacos) BuildDefaultServiceClient ¶ added in v1.1.9
func (m *Nacos) BuildDefaultServiceClient(webClient *WebClient) *ServiceClient
func (*Nacos) BuildServiceClientWithConfigKey ¶ added in v1.1.10
func (m *Nacos) BuildServiceClientWithConfigKey(webClient *WebClient, configKey string) *ServiceClient
func (*Nacos) GetDefaultNameingClient ¶
func (m *Nacos) GetDefaultNameingClient() naming_client.INamingClient
func (*Nacos) GetMetadata ¶
func (*Nacos) GetServiceNamingClient ¶
func (m *Nacos) GetServiceNamingClient(configKey string) naming_client.INamingClient
func (*Nacos) GetServiceNamingClients ¶
func (m *Nacos) GetServiceNamingClients() map[string]naming_client.INamingClient
type NacosBanlancer ¶ added in v1.0.15
type NacosBanlancer struct {
// contains filtered or unexported fields
}
type ObjectID ¶ added in v1.0.3
type ObjectID [12]byte
ObjectID is the BSON ObjectID type.
var NilObjectID ObjectID
NilObjectID is the zero value for ObjectID.
func NewObjectID ¶ added in v1.0.3
func NewObjectID() ObjectID
NewObjectID generates a new ObjectID.
func NewObjectIDFromTimestamp ¶ added in v1.0.3
NewObjectIDFromTimestamp generates a new ObjectID based on the given time.
func ObjectIDFromHex ¶ added in v1.0.3
ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.
func (ObjectID) MarshalJSON ¶ added in v1.0.3
MarshalJSON returns the ObjectID as a string
func (ObjectID) MarshalText ¶ added in v1.0.3
MarshalText returns the ObjectID as UTF-8-encoded text. Implementing this allows us to use ObjectID as a map key when marshalling JSON. See https://pkg.go.dev/encoding#TextMarshaler
func (*ObjectID) UnmarshalJSON ¶ added in v1.0.3
UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 24 bytes long, it will be populated with the hex representation of the ObjectID. If the byte slice is twelve bytes long, it will be populated with the BSON representation of the ObjectID. This method also accepts empty strings and decodes them as NilObjectID. For any other inputs, an error will be returned.
func (*ObjectID) UnmarshalText ¶ added in v1.0.3
UnmarshalText populates the byte slice with the ObjectID. Implementing this allows us to use ObjectID as a map key when unmarshalling JSON. See https://pkg.go.dev/encoding#TextUnmarshaler
type PageParam ¶ added in v1.0.5
type PageParam struct { PageIndex int `json:"pageIndex" form:"pageIndex"` PageSize int `json:"pageSize" form:"pageSize"` }
func (*PageParam) ParamLength ¶ added in v1.0.10
type PageResult ¶ added in v1.0.5
type PageResult struct { Total int64 `json:"total"` TotalPages int64 `json:"totalPages"` Data []any `json:"data"` }
func NewPageResult ¶ added in v1.0.5
func NewPageResult() *PageResult
func NewPageResultWithTotalAndDataLen ¶ added in v1.1.3
func NewPageResultWithTotalAndDataLen(total int64, l int) *PageResult
func NewPatgeResultWithTotal ¶ added in v1.1.3
func NewPatgeResultWithTotal(total int64) *PageResult
func (*PageResult) GetTotalPages ¶ added in v1.0.5
func (m *PageResult) GetTotalPages(pageSize int) int64
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func (*Redis) GetRedisClient ¶ added in v1.1.3
func (m *Redis) GetRedisClient() *redis.Client
func (*Redis) GetRedisClients ¶
type RequestHeaderFunc ¶ added in v1.0.18
type RestResult ¶ added in v1.0.5
type RestResult struct { Status int `json:"status"` Code string `json:"code"` Data any `json:"data"` Message string `json:"message"` }
func NewBadRequestRestResult ¶ added in v1.0.18
func NewBadRequestRestResult(data any, message string) *RestResult
func NewForbiddenRestResult ¶ added in v1.1.4
func NewForbiddenRestResult(data any, message string) *RestResult
func NewInternalServerErrorRestResult ¶ added in v1.0.18
func NewInternalServerErrorRestResult(data any, message string) *RestResult
func NewNotFoundRestResult ¶ added in v1.0.18
func NewNotFoundRestResult(data any, message string) *RestResult
func NewRestResult ¶ added in v1.0.17
func NewRestResult( status int, code string, data any, message string, ) *RestResult
func NewServiceUnavailableRestResult ¶ added in v1.1.4
func NewServiceUnavailableRestResult(data any, message string) *RestResult
func NewSuccessRestResult ¶ added in v1.0.18
func NewSuccessRestResult(data any, message string) *RestResult
func NewUnauthorizedRestResult ¶ added in v1.1.4
func NewUnauthorizedRestResult(data any, message string) *RestResult
type Scheduler ¶ added in v1.1.11
type Scheduler struct { Id string `json:"id"` Name string `json:"name"` InnerScheduler gocron.Scheduler `json:"-"` }
func NewScheduler ¶ added in v1.1.13
func (*Scheduler) JobsWaitingInQueue ¶ added in v1.1.15
func (*Scheduler) RemoveByTags ¶ added in v1.1.15
type ServiceClient ¶
type ServiceClient struct {
// contains filtered or unexported fields
}
func NewServiceClient ¶
func NewServiceClient( namingClient naming_client.INamingClient, webClient *WebClient, banlancer Banlancer) *ServiceClient
func (*ServiceClient) Delete ¶
func (m *ServiceClient) Delete( serviceName string, path string, urlValues url.Values, bodyValue any, encodingFunc EncodingFunc, funcs ...RequestHeaderFunc, ) (int, []byte, error)
func (*ServiceClient) Do ¶
func (m *ServiceClient) Do( serviceName string, method string, path string, urlValues url.Values, bodyValue any, encodingFunc EncodingFunc, funcs ...RequestHeaderFunc, ) (*http.Response, int, []byte, error)
func (*ServiceClient) Get ¶
func (m *ServiceClient) Get( serviceName string, path string, urlValues url.Values, encodingFunc EncodingFunc, funcs ...RequestHeaderFunc, ) (int, []byte, error)
func (*ServiceClient) Post ¶
func (m *ServiceClient) Post( serviceName string, path string, urlValues url.Values, bodyValue any, encodingFunc EncodingFunc, funcs ...RequestHeaderFunc, ) (int, []byte, error)
func (*ServiceClient) Put ¶
func (m *ServiceClient) Put( serviceName string, path string, urlValues url.Values, bodyValue any, encodingFunc EncodingFunc, funcs ...RequestHeaderFunc, ) (int, []byte, error)
type SystemMiddleware ¶ added in v1.0.14
type SystemVersion ¶ added in v1.0.6
type SystemVersion struct { ApplicationName string `json:"applicationName"` Version string `json:"version"` Profile string `json:"profile"` GoVersion string `json:"goVersion"` CurrentTime string `json:"currentTime"` }
func NewSystemVersion ¶ added in v1.0.6
func NewSystemVersion(version string, config *viper.Viper) *SystemVersion
type TencentEss ¶ added in v1.1.45
type TencentEss struct {
// contains filtered or unexported fields
}
func NewTencentEss ¶ added in v1.1.45
func NewTencentEss(config *viper.Viper) *TencentEss
func (*TencentEss) GetEssClient ¶ added in v1.1.45
func (m *TencentEss) GetEssClient() *ess.Client
func (*TencentEss) GetEssClients ¶ added in v1.1.45
func (m *TencentEss) GetEssClients() map[string]*TencentEssClient
func (*TencentEss) GetEssFileClient ¶ added in v1.1.50
func (m *TencentEss) GetEssFileClient() *ess.Client
func (*TencentEss) Init ¶ added in v1.1.45
func (m *TencentEss) Init()
type TencentEssClient ¶ added in v1.1.50
type TencentEssClient struct {
// contains filtered or unexported fields
}
func (*TencentEssClient) GetEssClient ¶ added in v1.1.50
func (m *TencentEssClient) GetEssClient() *ess.Client
func (*TencentEssClient) GetEssFileClient ¶ added in v1.1.50
func (m *TencentEssClient) GetEssFileClient() *ess.Client
type UpdateLog ¶ added in v1.1.39
type UpdateLog struct { Property string `json:"property"` OldValue string `json:"oldValue"` NewValue string `json:"newValue"` }
func NewUpdateLog ¶ added in v1.1.39
type WebClient ¶
func NewWebClient ¶
func (*WebClient) Get ¶
func (m *WebClient) Get( baseUrl string, path string, urlValues url.Values, encodingFunc EncodingFunc, funcs ...RequestHeaderFunc, ) (int, []byte, error)