Documentation ¶
Index ¶
- Constants
- Variables
- func Cleanup()
- func ContextTimeout(timeout time.Duration) echo.MiddlewareFunc
- func DefaultBeforeBreadcrumb(breadcrumb *sentry.Breadcrumb, hint *sentry.BreadcrumbHint) *sentry.Breadcrumb
- func DefaultBeforeSend(event *sentry.Event, hint *sentry.EventHint) *sentry.Event
- func Logger() echo.Logger
- func NewEcho() *echo.Echo
- func SentryCaptureException(c echo.Context, err error)
- func SentryCaptureMessage(c echo.Context, msg string)
- type Bean
- func (b *Bean) DefaultHTTPErrorHandler() echo.HTTPErrorHandler
- func (b *Bean) InitDB()
- func (b *Bean) ServeAt(host, port string)
- func (b *Bean) UseErrorHandlerFuncs(errHdlrFuncs ...berror.ErrorHandlerFunc)
- func (b *Bean) UseMiddlewares(middlewares ...echo.MiddlewareFunc)
- func (b *Bean) UseValidation(validateFuncs ...validator.ValidatorFunc)
- type Config
- type DBDeps
- type SentryConfig
Constants ¶
const SentryHubContextKey = "sentry"
This key is inherited from `sentryecho` package as the package doesn't support the key for external use.
Variables ¶
var BeanLogger echo.Logger
This is a global variable to hold the debug logger so that we can log data from service, repository or anywhere.
var NetHttpFastTransporter *http.Transport
Support a DNS cache version of the net/http Transport.
var TenantAlterDbHostParam string
If a command or service wants to use a different `host` parameter for tenant database connection then it's easy to do just by passing that parameter string name using `bean.TenantAlterDbHostParam`. Therfore, `bean` will overwrite all host string in `TenantConnections`.`Connections` JSON.
Functions ¶
func Cleanup ¶ added in v1.1.34
func Cleanup()
To clean up any bean resources before the program terminates. Call this function using `defer` like `defer Cleanup()`
func ContextTimeout ¶ added in v1.1.45
ContextTimeout return custom context timeout middleware
func DefaultBeforeBreadcrumb ¶ added in v1.1.18
func DefaultBeforeBreadcrumb(breadcrumb *sentry.Breadcrumb, hint *sentry.BreadcrumbHint) *sentry.Breadcrumb
Modify breadcrumbs through beforeBreadcrumb function.
func DefaultBeforeSend ¶ added in v1.1.18
func DefaultBeforeSend(event *sentry.Event, hint *sentry.EventHint) *sentry.Event
Modify event through beforeSend function.
func Logger ¶ added in v1.1.18
func Logger() echo.Logger
The bean Logger to have debug log from anywhere.
func SentryCaptureException ¶ added in v1.1.19
func SentryCaptureException(c echo.Context, err error)
This is a global function to send sentry exception if you configure the sentry through env.json. You cann pass a proper context or nil.
func SentryCaptureMessage ¶ added in v1.1.19
func SentryCaptureMessage(c echo.Context, msg string)
This is a global function to send sentry message if you configure the sentry through env.json. You cann pass a proper context or nil.
Types ¶
type Bean ¶
type Bean struct { DBConn *DBDeps Echo *echo.Echo BeforeServe func() Config Config // contains filtered or unexported fields }
func (*Bean) DefaultHTTPErrorHandler ¶
func (b *Bean) DefaultHTTPErrorHandler() echo.HTTPErrorHandler
func (*Bean) InitDB ¶
func (b *Bean) InitDB()
InitDB initialize all the database dependencies and store it in global variable `global.DBConn`.
func (*Bean) UseErrorHandlerFuncs ¶
func (b *Bean) UseErrorHandlerFuncs(errHdlrFuncs ...berror.ErrorHandlerFunc)
func (*Bean) UseMiddlewares ¶
func (b *Bean) UseMiddlewares(middlewares ...echo.MiddlewareFunc)
func (*Bean) UseValidation ¶
func (b *Bean) UseValidation(validateFuncs ...validator.ValidatorFunc)
type Config ¶
type Config struct { ProjectName string Environment string DebugLogPath string Secret string AccessLog struct { On bool BodyDump bool Path string BodyDumpMaskParam []string ReqHeaderParam []string SkipEndpoints []string } Prometheus struct { On bool SkipEndpoints []string } HTTP struct { Port string Host string BodyLimit string IsHttpsRedirect bool Timeout time.Duration ErrorMessage struct { E404 struct { Json []struct { Key string Value string } Html struct { File string } } E405 struct { Json []struct { Key string Value string } Html struct { File string } } E500 struct { Json []struct { Key string Value string } Html struct { File string } } E504 struct { Json []struct { Key string Value string } Html struct { File string } } Default struct { Json []struct { Key string Value string } Html struct { File string } } } KeepAlive bool AllowedMethod []string SSL struct { On bool CertFile string PrivFile string MinTLSVersion uint16 } } NetHttpFastTransporter struct { On bool MaxIdleConns *int MaxIdleConnsPerHost *int MaxConnsPerHost *int IdleConnTimeout *time.Duration DNSCacheTimeout *time.Duration } HTML struct { ViewsTemplateCache bool } Database struct { Tenant struct { On bool } MySQL dbdrivers.SQLConfig Mongo dbdrivers.MongoConfig Redis dbdrivers.RedisConfig Memory dbdrivers.MemoryConfig } Sentry SentryConfig Security struct { HTTP struct { Header struct { XssProtection string ContentTypeNosniff string XFrameOptions string HstsMaxAge int ContentSecurityPolicy string } } } AsyncPool []struct { Name string Size *int BlockAfter *int } }
var BeanConfig Config
Hold the useful configuration settings of bean so that we can use it quickly from anywhere.
type DBDeps ¶
type DBDeps struct { MasterMySQLDB *gorm.DB MasterMySQLDBName string TenantMySQLDBs map[uint64]*gorm.DB TenantMySQLDBNames map[uint64]string MasterMongoDB *mongo.Client MasterMongoDBName string TenantMongoDBs map[uint64]*mongo.Client TenantMongoDBNames map[uint64]string MasterRedisDB map[uint64]*dbdrivers.RedisDBConn TenantRedisDBs map[uint64]*dbdrivers.RedisDBConn MemoryDB *badger.DB }
All database connections are initialized using `DBDeps` structure.
Directories ¶
Path | Synopsis |
---|---|
Safe way to execute `go routine` without crashing the parent process while having a `panic`.
|
Safe way to execute `go routine` without crashing the parent process while having a `panic`. |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
bean
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Do not change this file.
|
Do not change this file. |
Package urlpath matches paths against a template.
|
Package urlpath matches paths against a template. |