rkmux

package
v1.2.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 42 Imported by: 1

Documentation

Overview

Package rkmux an implementation of rkentry.Entry which could be used start restful server with rkmux framework

Index

Constants

View Source
const (
	// MuxEntryType type of entry
	MuxEntryType = "MuxEntry"
)

Variables

This section is empty.

Functions

func RegisterMuxEntryYAML added in v1.0.0

func RegisterMuxEntryYAML(raw []byte) map[string]rkentry.Entry

RegisterMuxEntryYAML register Mux entries with provided config file (Must YAML file).

Currently, support two ways to provide config file filepath. 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 BootMux added in v1.0.0

type BootMux 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"`
		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"`
			Trace      rkmidtrace.BootConfig `yaml:"trace" json:"trace"`
		} `yaml:"middleware" json:"middleware"`
	} `yaml:"mux" json:"mux"`
}

BootMux boot config which is for Mux entry.

type MuxEntry

type MuxEntry struct {
	Port               uint64                          `json:"-" yaml:"-"`
	LoggerEntry        *rkentry.LoggerEntry            `json:"-" yaml:"-"`
	EventEntry         *rkentry.EventEntry             `json:"-" yaml:"-"`
	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:"-"`
	Middlewares        []mux.MiddlewareFunc            `json:"-" yaml:"-"`
	PromEntry          *rkentry.PromEntry              `json:"-" yaml:"-"`
	DocsEntry          *rkentry.DocsEntry              `json:"-" yaml:"-"`
	StaticFileEntry    *rkentry.StaticFileHandlerEntry `json:"-" yaml:"-"`
	PProfEntry         *rkentry.PProfEntry             `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

MuxEntry implements rkentry.Entry interface.

func GetMuxEntry

func GetMuxEntry(name string) *MuxEntry

GetMuxEntry Get MuxEntry from rkentry.GlobalAppCtx.

func RegisterMuxEntry

func RegisterMuxEntry(opts ...MuxEntryOption) *MuxEntry

RegisterMuxEntry register MuxEntry with options.

func (*MuxEntry) AddMiddleware added in v1.0.0

func (entry *MuxEntry) AddMiddleware(inters ...mux.MiddlewareFunc)

AddMiddleware Add middlewares. This function should be called before Bootstrap() called.

func (*MuxEntry) Bootstrap

func (entry *MuxEntry) Bootstrap(ctx context.Context)

Bootstrap MuxEntry.

func (*MuxEntry) GetDescription

func (entry *MuxEntry) GetDescription() string

GetDescription Get description of entry.

func (*MuxEntry) GetName

func (entry *MuxEntry) GetName() string

GetName Get entry name.

func (*MuxEntry) GetType

func (entry *MuxEntry) GetType() string

GetType Get entry type.

func (*MuxEntry) Interrupt

func (entry *MuxEntry) Interrupt(ctx context.Context)

Interrupt MuxEntry.

func (*MuxEntry) IsCommonServiceEnabled

func (entry *MuxEntry) IsCommonServiceEnabled() bool

IsCommonServiceEnabled Is common service entry enabled?

func (*MuxEntry) IsDocsEnabled added in v1.0.0

func (entry *MuxEntry) IsDocsEnabled() bool

IsDocsEnabled Is Docs entry enabled?

func (*MuxEntry) IsPProfEnabled added in v1.1.0

func (entry *MuxEntry) IsPProfEnabled() bool

IsPProfEnabled Is pprof entry enabled?

func (*MuxEntry) IsPromEnabled

func (entry *MuxEntry) IsPromEnabled() bool

IsPromEnabled Is prometheus entry enabled?

func (*MuxEntry) IsStaticFileHandlerEnabled added in v0.0.3

func (entry *MuxEntry) IsStaticFileHandlerEnabled() bool

IsStaticFileHandlerEnabled Is static file handler entry enabled?

func (*MuxEntry) IsSwEnabled

func (entry *MuxEntry) IsSwEnabled() bool

IsSwEnabled Is swagger entry enabled?

func (*MuxEntry) IsTlsEnabled

func (entry *MuxEntry) IsTlsEnabled() bool

IsTlsEnabled Is TLS enabled?

func (*MuxEntry) MarshalJSON

func (entry *MuxEntry) MarshalJSON() ([]byte, error)

MarshalJSON Marshal entry.

func (*MuxEntry) String

func (entry *MuxEntry) String() string

String Stringfy entry.

func (*MuxEntry) UnmarshalJSON

func (entry *MuxEntry) UnmarshalJSON([]byte) error

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 WithDocsEntry added in v1.0.0

func WithDocsEntry(docsEntry *rkentry.DocsEntry) MuxEntryOption

WithDocsEntry provide DocsEntry.

func WithEventEntry added in v1.0.0

func WithEventEntry(eventLogger *rkentry.EventEntry) MuxEntryOption

WithEventEntry provide rkentry.EventEntry.

func WithLoggerEntry added in v1.0.0

func WithLoggerEntry(zapLogger *rkentry.LoggerEntry) MuxEntryOption

WithLoggerEntry provide rkentry.LoggerEntry.

func WithName added in v0.0.3

func WithName(name string) MuxEntryOption

WithName provide name.

func WithPProfEntry added in v1.1.0

func WithPProfEntry(p *rkentry.PProfEntry) MuxEntryOption

WithPProfEntry provide rkentry.PProfEntry.

func WithPort added in v0.0.3

func WithPort(port uint64) MuxEntryOption

WithPort provide port.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL