Documentation ¶
Index ¶
- Constants
- Variables
- func Debug() bool
- func LogDebug(message string, args ...any)
- func LogErr(e error)
- func LogError(message string, args ...any)
- func LogInfo(message string, args ...any)
- func LogWarn(e error)
- func LogWarning(message string, args ...any)
- func SetDebug(value bool)
- func SetDefaultLogger(logger Logger)
- type AccessObject
- type BuilderPath
- type ClientContext
- type ClientSection
- type ClientWrapErrorFunc
- type EventArgs
- type EventBox
- type EventHandlerFunc
- type EventPool
- type HttpController
- type HttpHandlerAdapterFunc
- type HttpHandlerFunc
- type HttpMiddleware
- type HttpMiddlewareFunc
- type HttpRouter
- type Locker
- type LogLevel
- type Logger
- type LoggerAdapter
- func (l *LoggerAdapter) Caller(skip int) Logger
- func (l *LoggerAdapter) Debug(message string, args ...any)
- func (l *LoggerAdapter) Emit(message string, args ...any)
- func (l *LoggerAdapter) Err(e error)
- func (l *LoggerAdapter) Error(message string, args ...any)
- func (l *LoggerAdapter) Info(message string, args ...any)
- func (l *LoggerAdapter) Level() LogLevel
- func (l *LoggerAdapter) Warn(e error)
- func (l *LoggerAdapter) Warning(message string, args ...any)
- func (l *LoggerAdapter) With(name string) Logger
- type LoggerOptions
- type UnlockFunc
- type Validator
- type ValidatorTagNameFunc
Constants ¶
View Source
const (
LockerDefaultExpiry = time.Second
)
Variables ¶
View Source
var ( FactoryErrHttpResponseParseData = NewFactory( "errHttpResponseParseData", ErrorKindInternal, "response data is not valid") FactoryErrHttpResponseSendData = NewFactory( "errHttpResponseSendData", ErrorKindInternal, "response data is not send") FactoryErrHttpMultipartFormFile = NewFactory( "errHttpMultipartFormFile", ErrorKindSystem, "the file with the specified key '{{ .key }}' cannot be processed") "errHttpClientUnauthorized", ErrorKindUser, "401. client is unauthorized") FactoryErrHttpAccessForbidden = NewFactory( "errHttpAccessForbidden", ErrorKindUser, "403. access forbidden") FactoryErrHttpResourceNotFound = NewFactory( "errHttpResourceNotFound", ErrorKindUser, "404. resource not found") FactoryErrHttpRequestParseData = NewFactory( "errHttpRequestParseData", ErrorKindUser, "request body is not valid") FactoryErrHttpRequestParseParam = NewFactory( "errHttpRequestParseParam", ErrorKindUser, "request param with key '{{ .key }}' of type '{{ .type }}' contains incorrect value '{{ .value }}'") FactoryErrHttpRequestParamEmpty = NewFactory( "errHttpRequestParamEmpty", ErrorKindUser, "request param with key '{{ .key }}' is empty'") FactoryErrHttpRequestParamMax = NewFactory( "errHttpRequestParamMax", ErrorKindUser, "request param with key '{{ .key }}' contains value greater then max '{{ .max }}'") FactoryErrHttpRequestParamLenMax = NewFactory( "errHttpRequestParamLenMax", ErrorKindUser, "request param with key '{{ .key }}' has value length greater then max '{{ .maxLength }}' characters") )
View Source
var ( FactoryErrInternal = NewFactory( ErrorInternalID, ErrorKindInternal, "internal server error") FactoryErrInternalNotice = NewFactory( ErrorInternalID, ErrorKindInternalNotice, "internal server error") FactoryErrInternalNilPointer = NewFactory( "errInternalNilPointer", ErrorKindInternal, "nil pointer") FactoryErrInternalTypeAssertion = NewFactory( "errInternalTypeAssertion", ErrorKindInternal, "invalid type '{{ .type }}' assertion (value: {{ .value }})") FactoryErrInternalInvalidType = NewFactory( "errInternalInvalidType", ErrorKindInternal, "invalid type '{{ .currentType }}', expected: '{{ .expectedType }}'") FactoryErrInternalFailedToClose = NewFactory( "errInternalFailedToClose", ErrorKindInternal, "failed to close '{{ .name }}'") FactoryErrInternalWithData = NewFactory( "errInternalWithData", ErrorKindInternal, "{{ .key }}={{ .data }}") FactoryErrWithData = NewFactory( "errWithData", ErrorKindInternalNotice, "{{ .key }}={{ .data }}") )
View Source
var ( FactoryErrServiceOperationFailed = NewFactory( "errServiceOperationFailed", ErrorKindInternal, "operation failed") "errServiceTemporarilyUnavailable", ErrorKindSystem, "system is temporarily unavailable") FactoryErrServiceIncorrectInputData = NewFactory( "errServiceIncorrectInputData", ErrorKindInternalNotice, "{{ .key }}={{ .data }} is incorrect") FactoryErrServiceEntityNotFound = NewFactory( "errServiceEntityNotFound", ErrorKindUser, "entity not found") FactoryErrServiceEntityVersionInvalid = NewFactory( "errServiceEntityVersionInvalid", ErrorKindUser, "entity version is invalid") FactoryErrServiceSwitchStatusRejected = NewFactory( "errServiceSwitchStatusRejected", ErrorKindUser, "switching from '{{ .statusFrom }}' to '{{ .statusTo }}' is rejected") )
View Source
var ( FactoryErrStorageConnectionIsAlreadyCreated = NewFactory( "errStorageConnectionIsAlreadyCreated", ErrorKindInternal, "connection '{{ .name }}' is already created") FactoryErrStorageConnectionIsNotOpened = NewFactory( "errStorageConnectionIsNotOpened", ErrorKindInternal, "connection '{{ .name }}' is not opened") FactoryErrStorageConnectionFailed = NewFactory( "errStorageConnectionFailed", ErrorKindSystem, "connection '{{ .name }}' is failed") FactoryErrStorageQueryFailed = NewFactory( "errStorageQueryFailed", ErrorKindInternal, "query is failed") FactoryErrStorageFetchDataFailed = NewFactory( "errStorageFetchDataFailed", ErrorKindInternal, "fetching data is failed") FactoryErrStorageNoRowFound = NewFactory( "errStorageNoRowFound", ErrorKindInternalNotice, "no row found") FactoryErrStorageRowsNotAffected = NewFactory( "errStorageRowsNotAffected", ErrorKindInternalNotice, "rows not affected") )
Functions ¶
func LogWarning ¶ added in v0.7.0
func SetDebug ¶ added in v0.9.0
func SetDebug(value bool)
SetDebug - WARNING: use only when starting the main process
func SetDefaultLogger ¶
func SetDefaultLogger(logger Logger)
SetDefaultLogger - WARNING: use only when starting the main process
Types ¶
type AccessObject ¶ added in v0.6.0
type BuilderPath ¶ added in v0.7.0
type ClientContext ¶ added in v0.8.0
type ClientContext interface { Request() *http.Request ParamFromPath(name string) string Context() context.Context WithContext(ctx context.Context) ClientContext Writer() http.ResponseWriter Validate(structRequest any) error SendResponse(status int, structResponse any) error SendResponseNoContent() error SendFile(info mrtype.FileInfo, attachmentName string, file io.Reader) error }
type ClientSection ¶ added in v0.6.0
type ClientSection interface { Caption() string Path(actionPath string) string MiddlewareWithPermission(name string, next HttpHandlerFunc) HttpHandlerFunc }
type ClientWrapErrorFunc ¶ added in v0.9.1
type EventHandlerFunc ¶ added in v0.5.4
type HttpController ¶
type HttpController interface {
AddHandlers(router HttpRouter)
}
type HttpHandlerAdapterFunc ¶
type HttpHandlerAdapterFunc func(next HttpHandlerFunc) http.HandlerFunc
type HttpHandlerFunc ¶
type HttpHandlerFunc func(c ClientContext) error
type HttpMiddlewareFunc ¶
func (HttpMiddlewareFunc) Middleware ¶
func (f HttpMiddlewareFunc) Middleware(next http.Handler) http.Handler
type HttpRouter ¶
type HttpRouter interface { RegisterMiddleware(handlers ...HttpMiddleware) Register(controllers ...HttpController) HandlerFunc(method, path string, handler http.HandlerFunc) HttpHandlerFunc(method, path string, handler HttpHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) }
type Logger ¶
type Logger interface { With(name string) Logger Caller(skip int) Logger Level() LogLevel Error(message string, args ...any) Err(err error) Warning(message string, args ...any) Warn(err error) Info(message string, args ...any) Debug(message string, args ...any) }
func DefaultLogger ¶
func DefaultLogger() Logger
type LoggerAdapter ¶ added in v0.5.4
type LoggerAdapter struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(opt LoggerOptions) (*LoggerAdapter, error)
func (*LoggerAdapter) Caller ¶ added in v0.7.0
func (l *LoggerAdapter) Caller(skip int) Logger
func (*LoggerAdapter) Debug ¶ added in v0.5.4
func (l *LoggerAdapter) Debug(message string, args ...any)
func (*LoggerAdapter) Emit ¶ added in v0.5.4
func (l *LoggerAdapter) Emit(message string, args ...any)
func (*LoggerAdapter) Err ¶ added in v0.5.4
func (l *LoggerAdapter) Err(e error)
func (*LoggerAdapter) Error ¶ added in v0.5.4
func (l *LoggerAdapter) Error(message string, args ...any)
func (*LoggerAdapter) Info ¶ added in v0.5.4
func (l *LoggerAdapter) Info(message string, args ...any)
func (*LoggerAdapter) Level ¶ added in v0.9.0
func (l *LoggerAdapter) Level() LogLevel
func (*LoggerAdapter) Warn ¶ added in v0.5.4
func (l *LoggerAdapter) Warn(e error)
func (*LoggerAdapter) Warning ¶ added in v0.7.0
func (l *LoggerAdapter) Warning(message string, args ...any)
func (*LoggerAdapter) With ¶ added in v0.5.4
func (l *LoggerAdapter) With(name string) Logger
type LoggerOptions ¶ added in v0.9.2
type UnlockFunc ¶ added in v0.5.4
type UnlockFunc func()
type ValidatorTagNameFunc ¶
Click to show internal directories.
Click to hide internal directories.