Documentation
¶
Index ¶
- Constants
- Variables
- func LogDebug(message string, args ...any)
- func LogErr(e error)
- func LogError(message string, args ...any)
- func LogInfo(message string, args ...any)
- func LogWarn(message string, args ...any)
- func SetDefaultLogger(logger Logger)
- type AccessObject
- type ClientData
- type ClientSection
- 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) 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) Warn(message string, args ...any)
- func (l *LoggerAdapter) With(name string) Logger
- type RequestPath
- type UnlockFunc
- type Validator
- type ValidatorTagNameFunc
Constants ¶
View Source
const (
LockerDefaultExpiry = time.Second
)
Variables ¶
View Source
var ( FactoryErrHttpRequestParamEmpty = NewFactory( "errHttpRequestParamEmpty", ErrorKindUser, "request param with key '{{ .key }}' is empty'") FactoryErrHttpRequestParamMax = NewFactory( "errHttpRequestParamMax", ErrorKindUser, "request param with key '{{ .key }}' has value greater then max '{{ .max }}'") FactoryErrHttpRequestParamLenMax = NewFactory( "errHttpRequestParamLenMax", ErrorKindUser, "request param with key '{{ .key }}' has value length greater then max '{{ .maxLength }}'") FactoryErrHttpRequestParseParam = NewFactory( "errHttpRequestParseParam", ErrorKindUser, "request param of type '{{ .type }}' with key '{{ .key }}' contains incorrect value '{{ .value }}'") FactoryErrHttpRequestParseData = NewFactory( "errHttpRequestParseData", ErrorKindUser, "request body is not valid") FactoryErrHttpResponseParseData = NewFactory( "errHttpResponseParseData", ErrorKindInternal, "response data is not valid") FactoryErrHttpResponseSendData = NewFactory( "errHttpResponseSendData", ErrorKindInternal, "response data is not send") FactoryErrHttpResponseSystemTemporarilyUnableToProcess = NewFactory( "errHttpResponseSystemTemporarilyUnableToProcess", ErrorKindUser, "the system is temporarily unable to process your request. please try again") FactoryErrHttpResourceNotFound = NewFactory( "errHttpResourceNotFound", ErrorKindUser, "resource not found") )
View Source
var ( FactoryErrInternal = NewFactory( ErrorIdInternal, ErrorKindInternal, "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 '{{ .type1 }}', expected: '{{ .type2 }}'") FactoryErrInternalInvalidData = NewFactory( "errInternalInvalidData", ErrorKindInternal, "invalid data '{{ .value }}'") FactoryErrInternalParseData = NewFactory( "errInternalParseData", ErrorKindInternal, "data '{{ .name1 }}' parsed to {{ .name2 }} with error") FactoryErrInternalFailedToClose = NewFactory( "errInternalFailedToClose", ErrorKindInternal, "failed to close '{{ .name }}'") FactoryErrInternalMapValueNotFound = NewFactory( "errInternalMapValueNotFound", ErrorKindInternal, "'{{ .value }}' is not found in map {{ .name }}") FactoryErrInternalNoticeDataContainer = NewFactory( "errInternalNoticeDataContainer", ErrorKindInternalNotice, "data: '{{ .value }}'") )
View Source
var ( FactoryErrServiceEmptyInputData = NewFactory( "errServiceEmptyData", ErrorKindInternal, "{{ .name }} is empty") FactoryErrServiceIncorrectInputData = NewFactory( "errServiceIncorrectData", ErrorKindInternal, "data '{{ .data }}' is incorrect") "errServiceTemporarilyUnavailable", ErrorKindSystem, "resource '{{ .name }}' is temporarily unavailable") FactoryErrServiceEntityNotFound = NewFactory( "errServiceEntityNotFound", ErrorKindInternalNotice, "entity '{{ .name }}' is not found") FactoryErrServiceEntityNotCreated = NewFactory( "errServiceEntityNotCreated", ErrorKindSystem, "entity '{{ .name }}' is not created") FactoryErrServiceEntityNotUpdated = NewFactory( "errServiceEntityNotUpdated", ErrorKindSystem, "entity '{{ .name }}' is not updated") FactoryErrServiceEntityNotRemoved = NewFactory( "errServiceEntityNotRemoved", ErrorKindSystem, "entity '{{ .name }}' is not removed") FactoryErrServiceIncorrectSwitchStatus = NewFactory( "errServiceIncorrectSwitchStatus", ErrorKindInternalNotice, "incorrect switch status: '{{ .currentStatus }}' -> '{{ .statusTo }}' for entity '{{ .name }}(ID={{ .id }})'") )
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") FactoryErrStorageFetchedInvalidData = NewFactory( "errStorageFetchedInvalidData", ErrorKindInternal, "fetched data '{{ .value }}' is invalid") FactoryErrStorageNoRowFound = NewFactory( "errStorageNoRowFound", ErrorKindInternalNotice, "no row found") FactoryErrStorageRowsNotAffected = NewFactory( "errStorageRowsNotAffected", ErrorKindInternalNotice, "rows not affected") )
Functions ¶
func SetDefaultLogger ¶
func SetDefaultLogger(logger Logger)
SetDefaultLogger - WARNING!!! only for main process
Types ¶
type AccessObject ¶ added in v0.6.0
type ClientData ¶
type ClientData interface { Request() *http.Request RequestPath() RequestPath Context() context.Context WithContext(ctx context.Context) ClientData Writer() http.ResponseWriter Parse(structRequest any) error Validate(structRequest any) error ParseAndValidate(structRequest any) error SendResponse(status int, structResponse any) error SendResponseNoContent() error SendFile(contentType string, file io.Reader) error }
type ClientSection ¶ added in v0.6.0
type ClientSection interface { Path(actionPath string) string MiddlewareWithPermission(name string, next HttpHandlerFunc) HttpHandlerFunc }
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 ClientData) 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 Error(message string, args ...any) Err(err error) Warn(message string, args ...any) 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 (*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) Warn ¶ added in v0.5.4
func (l *LoggerAdapter) Warn(message string, args ...any)
func (*LoggerAdapter) With ¶ added in v0.5.4
func (l *LoggerAdapter) With(name string) Logger
type UnlockFunc ¶ added in v0.5.4
type UnlockFunc func()
type ValidatorTagNameFunc ¶
Click to show internal directories.
Click to hide internal directories.