Documentation ¶
Overview ¶
Package rkgin an implementation of rkentry.Entry which could be used start restful server with gin framework
Index ¶
- Constants
- func RegisterGinEntriesWithConfig(configFilePath string) map[string]rkentry.Entry
- type BootConfig
- type GinEntry
- func (entry *GinEntry) AddInterceptor(inters ...gin.HandlerFunc)
- func (entry *GinEntry) Apis(ctx *gin.Context)
- 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) IsPromEnabled() bool
- func (entry *GinEntry) IsStaticFileHandlerEnabled() bool
- func (entry *GinEntry) IsSwEnabled() bool
- func (entry *GinEntry) IsTlsEnabled() bool
- func (entry *GinEntry) IsTvEnabled() bool
- func (entry *GinEntry) MarshalJSON() ([]byte, error)
- func (entry *GinEntry) Req(ctx *gin.Context)
- func (entry *GinEntry) String() string
- func (entry *GinEntry) TV(ctx *gin.Context)
- 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 WithEventLoggerEntry(eventLogger *rkentry.EventLoggerEntry) GinEntryOption
- func WithName(name string) GinEntryOption
- func WithPort(port uint64) GinEntryOption
- func WithPromEntry(prom *rkentry.PromEntry) GinEntryOption
- func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) GinEntryOption
- func WithSwEntry(sw *rkentry.SwEntry) GinEntryOption
- func WithTvEntry(tvEntry *rkentry.TvEntry) GinEntryOption
- func WithZapLoggerEntry(zapLogger *rkentry.ZapLoggerEntry) GinEntryOption
Constants ¶
const ( // GinEntryType type of entry GinEntryType = "Gin" // GinEntryDescription description of entry GinEntryDescription = "Internal RK entry which helps to bootstrap with Gin framework." )
Variables ¶
This section is empty.
Functions ¶
func RegisterGinEntriesWithConfig ¶ added in v1.2.0
RegisterGinEntriesWithConfig 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 BootConfig ¶ added in v1.2.15
type BootConfig 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"` CertEntry string `yaml:"certEntry" json:"certEntry"` SW rkentry.BootConfigSw `yaml:"sw" json:"sw"` CommonService rkentry.BootConfigCommonService `yaml:"commonService" json:"commonService"` TV rkentry.BootConfigTv `yaml:"tv" json:"tv"` Prom rkentry.BootConfigProm `yaml:"prom" json:"prom"` Static rkentry.BootConfigStaticHandler `yaml:"static" json:"static"` Interceptors struct { LoggingZap rkmidlog.BootConfig `yaml:"loggingZap" json:"loggingZap"` MetricsProm rkmidmetrics.BootConfig `yaml:"metricsProm" json:"metricsProm"` 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"` Gzip struct { Enabled bool `yaml:"enabled" json:"enabled"` Level string `yaml:"level" json:"level"` } `yaml:"gzip" json:"gzip"` Timeout rkmidtimeout.BootConfig `yaml:"timeout" json:"timeout"` TracingTelemetry rkmidtrace.BootConfig `yaml:"tracingTelemetry" json:"tracingTelemetry"` } `yaml:"interceptors" json:"interceptors"` Logger struct { ZapLogger string `yaml:"zapLogger" json:"zapLogger"` EventLogger string `yaml:"eventLogger" json:"eventLogger"` } `yaml:"logger" json:"logger"` } `yaml:"gin" json:"gin"` }
BootConfig boot config which is for gin entry.
type GinEntry ¶
type GinEntry struct { EntryName string `json:"entryName" yaml:"entryName"` EntryType string `json:"entryType" yaml:"entryType"` EntryDescription string `json:"-" yaml:"-"` ZapLoggerEntry *rkentry.ZapLoggerEntry `json:"-" yaml:"-"` EventLoggerEntry *rkentry.EventLoggerEntry `json:"-" yaml:"-"` Router *gin.Engine `json:"-" yaml:"-"` Server *http.Server `json:"-" yaml:"-"` Port uint64 `json:"port" yaml:"port"` SwEntry *rkentry.SwEntry `json:"-" yaml:"-"` CertEntry *rkentry.CertEntry `json:"-" yaml:"-"` CommonServiceEntry *rkentry.CommonServiceEntry `json:"-" yaml:"-"` PromEntry *rkentry.PromEntry `json:"-" yaml:"-"` StaticFileEntry *rkentry.StaticFileHandlerEntry `json:"-" yaml:"-"` TvEntry *rkentry.TvEntry `json:"-" yaml:"-"` }
GinEntry implements rkentry.Entry interface.
func GetGinEntry ¶ added in v1.2.0
GetGinEntry Get GinEntry from rkentry.GlobalAppCtx.
func RegisterGinEntry ¶ added in v1.2.0
func RegisterGinEntry(opts ...GinEntryOption) *GinEntry
RegisterGinEntry register GinEntry with options.
func (*GinEntry) AddInterceptor ¶ added in v1.2.0
func (entry *GinEntry) AddInterceptor(inters ...gin.HandlerFunc)
AddInterceptor Add interceptors. This function should be called before Bootstrap() called.
func (*GinEntry) GetDescription ¶ added in v1.2.0
GetDescription Get description of entry.
func (*GinEntry) IsCommonServiceEnabled ¶ added in v1.2.0
IsCommonServiceEnabled Is common service entry enabled?
func (*GinEntry) IsPromEnabled ¶ added in v1.2.0
IsPromEnabled Is prometheus entry enabled?
func (*GinEntry) IsStaticFileHandlerEnabled ¶ added in v1.2.11
IsStaticFileHandlerEnabled Is static file handler entry enabled?
func (*GinEntry) IsSwEnabled ¶ added in v1.2.0
IsSwEnabled Is swagger entry enabled?
func (*GinEntry) IsTlsEnabled ¶ added in v1.1.3
IsTlsEnabled Is TLS enabled?
func (*GinEntry) IsTvEnabled ¶ added in v1.2.0
IsTvEnabled Is TV entry enabled?
func (*GinEntry) MarshalJSON ¶ added in v1.2.0
MarshalJSON Marshal entry.
func (*GinEntry) UnmarshalJSON ¶ added in v1.2.0
UnmarshalJSON Not supported.
type GinEntryOption ¶
type GinEntryOption func(*GinEntry)
GinEntryOption Gin entry option.
func WithCertEntry ¶ added in v1.2.15
func WithCertEntry(certEntry *rkentry.CertEntry) GinEntryOption
WithCertEntry provide rkentry.CertEntry.
func WithCommonServiceEntry ¶ added in v1.2.15
func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) GinEntryOption
WithCommonServiceEntry provide CommonServiceEntry.
func WithDescription ¶ added in v1.2.15
func WithDescription(description string) GinEntryOption
WithDescription provide name.
func WithEventLoggerEntry ¶ added in v1.2.15
func WithEventLoggerEntry(eventLogger *rkentry.EventLoggerEntry) GinEntryOption
WithEventLoggerEntry provide rkentry.EventLoggerEntry.
func WithPromEntry ¶ added in v1.2.15
func WithPromEntry(prom *rkentry.PromEntry) GinEntryOption
WithPromEntry provide PromEntry.
func WithStaticFileHandlerEntry ¶ added in v1.2.15
func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) GinEntryOption
WithStaticFileHandlerEntry provide StaticFileHandlerEntry.
func WithSwEntry ¶ added in v1.2.15
func WithSwEntry(sw *rkentry.SwEntry) GinEntryOption
WithSwEntry provide SwEntry.
func WithTvEntry ¶ added in v1.2.15
func WithTvEntry(tvEntry *rkentry.TvEntry) GinEntryOption
WithTvEntry provide TvEntry.
func WithZapLoggerEntry ¶ added in v1.2.15
func WithZapLoggerEntry(zapLogger *rkentry.ZapLoggerEntry) GinEntryOption
WithZapLoggerEntry provide rkentry.ZapLoggerEntry.