Documentation
¶
Overview ¶
Package rkgin an implementation of rkentry.Entry which could be used start restful server with gin framework
Index ¶
- Constants
- func RegisterGinEntryYAML(raw []byte) map[string]rkentry.Entry
- type BootGin
- type GinEntry
- func (entry *GinEntry) AddMiddleware(mids ...gin.HandlerFunc)
- func (entry *GinEntry) Bootstrap(ctx context.Context)
- func (entry *GinEntry) GetDescription() string
- func (entry *GinEntry) GetName() string
- func (entry *GinEntry) GetType() string
- func (entry *GinEntry) Interrupt(ctx context.Context)
- func (entry *GinEntry) IsCommonServiceEnabled() bool
- func (entry *GinEntry) IsDocsEnabled() bool
- func (entry *GinEntry) IsPProfEnabled() bool
- func (entry *GinEntry) IsPromEnabled() bool
- func (entry *GinEntry) IsStaticFileHandlerEnabled() bool
- func (entry *GinEntry) IsSwEnabled() bool
- func (entry *GinEntry) IsTlsEnabled() bool
- func (entry *GinEntry) MarshalJSON() ([]byte, error)
- func (entry *GinEntry) SetLivenessCheck(f rkentry.LivenessCheck)
- func (entry *GinEntry) SetReadinessCheck(f rkentry.ReadinessCheck)
- func (entry *GinEntry) String() string
- func (entry *GinEntry) UnmarshalJSON([]byte) error
- type GinEntryOption
- func WithCertEntry(certEntry *rkentry.CertEntry) GinEntryOption
- func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) GinEntryOption
- func WithDescription(description string) GinEntryOption
- func WithDocsEntry(docs *rkentry.DocsEntry) GinEntryOption
- func WithEventEntry(eventLogger *rkentry.EventEntry) GinEntryOption
- func WithLoggerEntry(logger *rkentry.LoggerEntry) GinEntryOption
- func WithName(name string) GinEntryOption
- func WithPProfEntry(p *rkentry.PProfEntry) GinEntryOption
- func WithPort(port uint64) GinEntryOption
- func WithPromEntry(prom *rkentry.PromEntry) GinEntryOption
- func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) GinEntryOption
- func WithSwEntry(sw *rkentry.SWEntry) GinEntryOption
Constants ¶
const (
// GinEntryType type of entry
GinEntryType = "GinEntry"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterGinEntryYAML ¶
RegisterGinEntryYAML register gin entries with provided config file (Must YAML file).
Currently, support two ways to provide config file path. 1: With function parameters 2: With command line flag "--rkboot" described in rkcommon.BootConfigPathFlagKey (Will override function parameter if exists) Command line flag has high priority which would override function parameter
Error handling: Process will shutdown if any errors occur with rkcommon.ShutdownWithError function
Override elements in config file: We learned from HELM source code which would override elements in YAML file with "--set" flag followed with comma separated key/value pairs.
We are using "--rkset" described in rkcommon.BootConfigOverrideKey in order to distinguish with user flags Example of common usage: ./binary_file --rkset "key1=val1,key2=val2" Example of nested map: ./binary_file --rkset "outer.inner.key=val" Example of slice: ./binary_file --rkset "outer[0].key=val"
Types ¶
type BootGin ¶
type BootGin struct { Gin []struct { Enabled bool `yaml:"enabled" json:"enabled"` Name string `yaml:"name" json:"name"` Port uint64 `yaml:"port" json:"port"` Description string `yaml:"description" json:"description"` SW rkentry.BootSW `yaml:"sw" json:"sw"` Docs rkentry.BootDocs `yaml:"docs" json:"docs"` CommonService rkentry.BootCommonService `yaml:"commonService" json:"commonService"` Prom rkentry.BootProm `yaml:"prom" json:"prom"` CertEntry string `yaml:"certEntry" json:"certEntry"` LoggerEntry string `yaml:"loggerEntry" json:"loggerEntry"` EventEntry string `yaml:"eventEntry" json:"eventEntry"` Static rkentry.BootStaticFileHandler `yaml:"static" json:"static"` PProf rkentry.BootPProf `yaml:"pprof" json:"pprof"` Middleware struct { Ignore []string `yaml:"ignore" json:"ignore"` ErrorModel string `yaml:"errorModel" json:"errorModel"` Logging rkmidlog.BootConfig `yaml:"logging" json:"logging"` Prom rkmidprom.BootConfig `yaml:"prom" json:"prom"` Auth rkmidauth.BootConfig `yaml:"auth" json:"auth"` Cors rkmidcors.BootConfig `yaml:"cors" json:"cors"` Meta rkmidmeta.BootConfig `yaml:"meta" json:"meta"` Jwt rkmidjwt.BootConfig `yaml:"jwt" json:"jwt"` Secure rkmidsec.BootConfig `yaml:"secure" json:"secure"` RateLimit rkmidlimit.BootConfig `yaml:"rateLimit" json:"rateLimit"` Csrf rkmidcsrf.BootConfig `yaml:"csrf" yaml:"csrf"` Timeout rkmidtimeout.BootConfig `yaml:"timeout" json:"timeout"` Trace rkmidtrace.BootConfig `yaml:"trace" json:"trace"` Gzip struct { Enabled bool `yaml:"enabled" json:"enabled"` Ignore []string `yaml:"ignore" json:"ignore"` Level string `yaml:"level" json:"level"` } `yaml:"gzip" json:"gzip"` } `yaml:"middleware" json:"middleware"` } `yaml:"gin" json:"gin"` }
BootGin boot config which is for gin entry.
type GinEntry ¶
type GinEntry struct { Router *gin.Engine `json:"-" yaml:"-"` Server *http.Server `json:"-" yaml:"-"` Port uint64 `json:"-" yaml:"-"` LoggerEntry *rkentry.LoggerEntry `json:"-" yaml:"-"` EventEntry *rkentry.EventEntry `json:"-" yaml:"-"` SwEntry *rkentry.SWEntry `json:"-" yaml:"-"` DocsEntry *rkentry.DocsEntry `json:"-" yaml:"-"` CommonServiceEntry *rkentry.CommonServiceEntry `json:"-" yaml:"-"` PromEntry *rkentry.PromEntry `json:"-" yaml:"-"` StaticFileEntry *rkentry.StaticFileHandlerEntry `json:"-" yaml:"-"` CertEntry *rkentry.CertEntry `json:"-" yaml:"-"` PProfEntry *rkentry.PProfEntry `json:"-" yaml:"-"` // contains filtered or unexported fields }
GinEntry implements rkentry.Entry interface.
func GetGinEntry ¶
GetGinEntry Get GinEntry from rkentry.GlobalAppCtx.
func RegisterGinEntry ¶
func RegisterGinEntry(opts ...GinEntryOption) *GinEntry
RegisterGinEntry register GinEntry with options.
func (*GinEntry) AddMiddleware ¶
func (entry *GinEntry) AddMiddleware(mids ...gin.HandlerFunc)
AddMiddleware Add interceptors. This function should be called before Bootstrap() called.
func (*GinEntry) GetDescription ¶
GetDescription Get description of entry.
func (*GinEntry) IsCommonServiceEnabled ¶
IsCommonServiceEnabled Is common service entry enabled?
func (*GinEntry) IsDocsEnabled ¶
IsDocsEnabled Is docs entry enabled?
func (*GinEntry) IsPProfEnabled ¶ added in v2.1.0
IsPProfEnabled Is pprof entry enabled?
func (*GinEntry) IsPromEnabled ¶
IsPromEnabled Is prometheus entry enabled?
func (*GinEntry) IsStaticFileHandlerEnabled ¶
IsStaticFileHandlerEnabled Is static file handler entry enabled?
func (*GinEntry) IsSwEnabled ¶
IsSwEnabled Is swagger entry enabled?
func (*GinEntry) IsTlsEnabled ¶
IsTlsEnabled Is TLS enabled?
func (*GinEntry) MarshalJSON ¶
MarshalJSON Marshal entry.
func (*GinEntry) SetLivenessCheck ¶
func (entry *GinEntry) SetLivenessCheck(f rkentry.LivenessCheck)
SetLivenessCheck set liveness check into rkentry.GlobalAppCtx
func (*GinEntry) SetReadinessCheck ¶
func (entry *GinEntry) SetReadinessCheck(f rkentry.ReadinessCheck)
SetReadinessCheck set readiness check into rkentry.GlobalAppCtx
func (*GinEntry) UnmarshalJSON ¶
UnmarshalJSON Not supported.
type GinEntryOption ¶
type GinEntryOption func(*GinEntry)
GinEntryOption Gin entry option.
func WithCertEntry ¶
func WithCertEntry(certEntry *rkentry.CertEntry) GinEntryOption
WithCertEntry provide rkentry.CertEntry.
func WithCommonServiceEntry ¶
func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) GinEntryOption
WithCommonServiceEntry provide CommonServiceEntry.
func WithDescription ¶
func WithDescription(description string) GinEntryOption
WithDescription provide name.
func WithDocsEntry ¶
func WithDocsEntry(docs *rkentry.DocsEntry) GinEntryOption
WithDocsEntry provide SwEntry.
func WithEventEntry ¶
func WithEventEntry(eventLogger *rkentry.EventEntry) GinEntryOption
WithEventEntry provide rkentry.EventLoggerEntry.
func WithLoggerEntry ¶
func WithLoggerEntry(logger *rkentry.LoggerEntry) GinEntryOption
WithLoggerEntry provide rkentry.LoggerEntry.
func WithPProfEntry ¶ added in v2.1.0
func WithPProfEntry(p *rkentry.PProfEntry) GinEntryOption
func WithPromEntry ¶
func WithPromEntry(prom *rkentry.PromEntry) GinEntryOption
WithPromEntry provide PromEntry.
func WithStaticFileHandlerEntry ¶
func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) GinEntryOption
WithStaticFileHandlerEntry provide StaticFileHandlerEntry.
func WithSwEntry ¶
func WithSwEntry(sw *rkentry.SWEntry) GinEntryOption
WithSwEntry provide SwEntry.