Documentation
¶
Overview ¶
Package rkmux an implementation of rkentry.Entry which could be used start restful server with rkmux framework
Index ¶
- Constants
- func RegisterMuxEntriesWithConfig(configFilePath string) map[string]rkentry.Entry
- type BootConfig
- type MuxEntry
- func (entry *MuxEntry) AddInterceptor(inters ...mux.MiddlewareFunc)
- func (entry *MuxEntry) Apis(writer http.ResponseWriter, req *http.Request)
- func (entry *MuxEntry) Bootstrap(ctx context.Context)
- func (entry *MuxEntry) GetDescription() string
- func (entry *MuxEntry) GetName() string
- func (entry *MuxEntry) GetType() string
- func (entry *MuxEntry) Interrupt(ctx context.Context)
- func (entry *MuxEntry) IsCommonServiceEnabled() bool
- func (entry *MuxEntry) IsPromEnabled() bool
- func (entry *MuxEntry) IsStaticFileHandlerEnabled() bool
- func (entry *MuxEntry) IsSwEnabled() bool
- func (entry *MuxEntry) IsTlsEnabled() bool
- func (entry *MuxEntry) IsTvEnabled() bool
- func (entry *MuxEntry) MarshalJSON() ([]byte, error)
- func (entry *MuxEntry) Req(writer http.ResponseWriter, req *http.Request)
- func (entry *MuxEntry) String() string
- func (entry *MuxEntry) TV(writer http.ResponseWriter, req *http.Request)
- func (entry *MuxEntry) UnmarshalJSON([]byte) error
- type MuxEntryOption
- func WithCertEntry(certEntry *rkentry.CertEntry) MuxEntryOption
- func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) MuxEntryOption
- func WithDescription(description string) MuxEntryOption
- func WithEventLoggerEntry(eventLogger *rkentry.EventLoggerEntry) MuxEntryOption
- func WithName(name string) MuxEntryOption
- func WithPort(port uint64) MuxEntryOption
- func WithPromEntry(prom *rkentry.PromEntry) MuxEntryOption
- func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) MuxEntryOption
- func WithSwEntry(sw *rkentry.SwEntry) MuxEntryOption
- func WithTvEntry(tvEntry *rkentry.TvEntry) MuxEntryOption
- func WithZapLoggerEntry(zapLogger *rkentry.ZapLoggerEntry) MuxEntryOption
Constants ¶
const ( // MuxEntryType type of entry MuxEntryType = "Mux" // MuxEntryDescription description of entry MuxEntryDescription = "Internal RK entry which helps to bootstrap with mux framework." )
Variables ¶
This section is empty.
Functions ¶
func RegisterMuxEntriesWithConfig ¶
RegisterMuxEntriesWithConfig register Mux 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 v0.0.3
type BootConfig struct { Mux []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"` 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:"mux" json:"mux"` }
BootConfig boot config which is for Mux entry.
type MuxEntry ¶
type MuxEntry 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:"-"` Port uint64 `json:"port" yaml:"port"` CertEntry *rkentry.CertEntry `json:"-" yaml:"-"` SwEntry *rkentry.SwEntry `json:"-" yaml:"-"` CommonServiceEntry *rkentry.CommonServiceEntry `json:"-" yaml:"-"` Router *mux.Router `json:"-" yaml:"-"` Server *http.Server `json:"-" yaml:"-"` TlsConfig *tls.Config `json:"-" yaml:"-"` Interceptors []mux.MiddlewareFunc `json:"-" yaml:"-"` PromEntry *rkentry.PromEntry `json:"-" yaml:"-"` TvEntry *rkentry.TvEntry `json:"-" yaml:"-"` StaticFileEntry *rkentry.StaticFileHandlerEntry `json:"-" yaml:"-"` }
MuxEntry implements rkentry.Entry interface.
func GetMuxEntry ¶
GetMuxEntry Get MuxEntry from rkentry.GlobalAppCtx.
func RegisterMuxEntry ¶
func RegisterMuxEntry(opts ...MuxEntryOption) *MuxEntry
RegisterMuxEntry register MuxEntry with options.
func (*MuxEntry) AddInterceptor ¶
func (entry *MuxEntry) AddInterceptor(inters ...mux.MiddlewareFunc)
AddInterceptor Add interceptors. This function should be called before Bootstrap() called.
func (*MuxEntry) Apis ¶ added in v0.0.3
func (entry *MuxEntry) Apis(writer http.ResponseWriter, req *http.Request)
Apis list apis
func (*MuxEntry) GetDescription ¶
GetDescription Get description of entry.
func (*MuxEntry) IsCommonServiceEnabled ¶
IsCommonServiceEnabled Is common service entry enabled?
func (*MuxEntry) IsPromEnabled ¶
IsPromEnabled Is prometheus entry enabled?
func (*MuxEntry) IsStaticFileHandlerEnabled ¶ added in v0.0.3
IsStaticFileHandlerEnabled Is static file handler entry enabled?
func (*MuxEntry) IsSwEnabled ¶
IsSwEnabled Is swagger entry enabled?
func (*MuxEntry) IsTlsEnabled ¶
IsTlsEnabled Is TLS enabled?
func (*MuxEntry) IsTvEnabled ¶
IsTvEnabled Is TV entry enabled?
func (*MuxEntry) MarshalJSON ¶
MarshalJSON Marshal entry.
func (*MuxEntry) Req ¶ added in v0.0.3
func (entry *MuxEntry) Req(writer http.ResponseWriter, req *http.Request)
Req handler
func (*MuxEntry) TV ¶ added in v0.0.3
func (entry *MuxEntry) TV(writer http.ResponseWriter, req *http.Request)
TV handler
func (*MuxEntry) UnmarshalJSON ¶
UnmarshalJSON Not supported.
type MuxEntryOption ¶
type MuxEntryOption func(*MuxEntry)
MuxEntryOption Mux entry option.
func WithCertEntry ¶ added in v0.0.3
func WithCertEntry(certEntry *rkentry.CertEntry) MuxEntryOption
WithCertEntry provide rkentry.CertEntry.
func WithCommonServiceEntry ¶ added in v0.0.3
func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) MuxEntryOption
WithCommonServiceEntry provide CommonServiceEntry.
func WithDescription ¶ added in v0.0.3
func WithDescription(description string) MuxEntryOption
WithDescription provide name.
func WithEventLoggerEntry ¶ added in v0.0.3
func WithEventLoggerEntry(eventLogger *rkentry.EventLoggerEntry) MuxEntryOption
WithEventLoggerEntry provide rkentry.EventLoggerEntry.
func WithPromEntry ¶ added in v0.0.3
func WithPromEntry(prom *rkentry.PromEntry) MuxEntryOption
WithPromEntry provide PromEntry.
func WithStaticFileHandlerEntry ¶ added in v0.0.3
func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) MuxEntryOption
WithStaticFileHandlerEntry provide StaticFileHandlerEntry.
func WithSwEntry ¶ added in v0.0.3
func WithSwEntry(sw *rkentry.SwEntry) MuxEntryOption
WithSwEntry provide SwEntry.
func WithTvEntry ¶ added in v0.0.3
func WithTvEntry(tvEntry *rkentry.TvEntry) MuxEntryOption
WithTvEntry provide TvEntry.
func WithZapLoggerEntry ¶ added in v0.0.3
func WithZapLoggerEntry(zapLogger *rkentry.ZapLoggerEntry) MuxEntryOption
WithZapLoggerEntry provide rkentry.ZapLoggerEntry.