rkfiber

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 45 Imported by: 3

Documentation

Overview

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

Index

Constants

View Source
const (
	// FiberEntryType type of entry
	FiberEntryType = "FiberEntry"
)

Variables

This section is empty.

Functions

func RegisterFiberEntryYAML added in v1.0.0

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

RegisterFiberEntryYAML register fiber 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 rkentry.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 rkentry.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 rkentry.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 BootFiber added in v1.0.0

type BootFiber struct {
	Fiber []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"`
		LoggerEntry   string                        `yaml:"loggerEntry" json:"loggerEntry"`
		EventEntry    string                        `yaml:"eventEntry" json:"eventEntry"`
		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"`
		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"`
			Csrf       rkmidcsrf.BootConfig    `yaml:"csrf" yaml:"csrf"`
			RateLimit  rkmidlimit.BootConfig   `yaml:"rateLimit" json:"rateLimit"`
			Timeout    rkmidtimeout.BootConfig `yaml:"timeout" json:"timeout"`
			Trace      rkmidtrace.BootConfig   `yaml:"trace" json:"trace"`
		} `yaml:"middleware" json:"middleware"`
	} `yaml:"fiber" json:"fiber"`
}

BootFiber boot config which is for fiber entry.

type FiberEntry

type FiberEntry struct {
	LoggerEntry        *rkentry.LoggerEntry            `json:"-" yaml:"-"`
	EventEntry         *rkentry.EventEntry             `json:"-" yaml:"-"`
	CertEntry          *rkentry.CertEntry              `json:"-" yaml:"-"`
	Port               uint64                          `json:"-" yaml:"-"`
	SwEntry            *rkentry.SWEntry                `json:"-" yaml:"-"`
	CommonServiceEntry *rkentry.CommonServiceEntry     `json:"-" yaml:"-"`
	App                *fiber.App                      `json:"-" yaml:"-"`
	FiberConfig        *fiber.Config                   `json:"-" yaml:"-"`
	Middlewares        []fiber.Handler                 `json:"-" yaml:"-"`
	PromEntry          *rkentry.PromEntry              `json:"-" yaml:"-"`
	StaticFileEntry    *rkentry.StaticFileHandlerEntry `json:"-" yaml:"-"`
	DocsEntry          *rkentry.DocsEntry              `json:"-" yaml:"-"`
	PProfEntry         *rkentry.PProfEntry             `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

FiberEntry implements rkentry.Entry interface.

func GetFiberEntry

func GetFiberEntry(name string) *FiberEntry

GetFiberEntry Get FiberEntry from rkentry.GlobalAppCtx.

func RegisterFiberEntry

func RegisterFiberEntry(opts ...FiberEntryOption) *FiberEntry

RegisterFiberEntry register FiberEntry with options.

func (*FiberEntry) AddMiddleware added in v1.0.0

func (entry *FiberEntry) AddMiddleware(inters ...fiber.Handler)

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

func (*FiberEntry) Bootstrap

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

Bootstrap FiberEntry.

func (*FiberEntry) GetDescription

func (entry *FiberEntry) GetDescription() string

GetDescription Get description of entry.

func (*FiberEntry) GetName

func (entry *FiberEntry) GetName() string

GetName Get entry name.

func (*FiberEntry) GetType

func (entry *FiberEntry) GetType() string

GetType Get entry type.

func (*FiberEntry) Interrupt

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

Interrupt FiberEntry.

func (*FiberEntry) IsCommonServiceEnabled

func (entry *FiberEntry) IsCommonServiceEnabled() bool

IsCommonServiceEnabled Is common service entry enabled?

func (*FiberEntry) IsDocsEnabled added in v1.0.0

func (entry *FiberEntry) IsDocsEnabled() bool

IsDocsEnabled Is TV entry enabled?

func (*FiberEntry) IsPProfEnabled added in v1.1.0

func (entry *FiberEntry) IsPProfEnabled() bool

IsPProfEnabled Is pprof entry enabled?

func (*FiberEntry) IsPromEnabled

func (entry *FiberEntry) IsPromEnabled() bool

IsPromEnabled Is prometheus entry enabled?

func (*FiberEntry) IsStaticFileHandlerEnabled

func (entry *FiberEntry) IsStaticFileHandlerEnabled() bool

IsStaticFileHandlerEnabled Is static file handler entry enabled?

func (*FiberEntry) IsSwEnabled

func (entry *FiberEntry) IsSwEnabled() bool

IsSwEnabled Is swagger entry enabled?

func (*FiberEntry) IsTlsEnabled

func (entry *FiberEntry) IsTlsEnabled() bool

IsTlsEnabled Is TLS enabled?

func (*FiberEntry) MarshalJSON

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

MarshalJSON Marshal entry.

func (*FiberEntry) RefreshFiberRoutes added in v0.0.4

func (entry *FiberEntry) RefreshFiberRoutes()

RefreshFiberRoutes will rebuild fiber app tree, this is required!!! Why not create fiber.App before bootstrap?

This is because we hope to provide user specified fiber.Config which can override our custom settings.

func (*FiberEntry) SetFiberConfig

func (entry *FiberEntry) SetFiberConfig(conf *fiber.Config)

SetFiberConfig override fiber config

func (*FiberEntry) String

func (entry *FiberEntry) String() string

String Stringfy entry.

func (*FiberEntry) UnmarshalJSON

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

UnmarshalJSON Not supported.

type FiberEntryOption

type FiberEntryOption func(*FiberEntry)

FiberEntryOption Fiber entry option.

func WithCertEntry added in v0.0.5

func WithCertEntry(certEntry *rkentry.CertEntry) FiberEntryOption

WithCertEntry provide rkentry.CertEntry.

func WithCommonServiceEntry added in v0.0.5

func WithCommonServiceEntry(commonServiceEntry *rkentry.CommonServiceEntry) FiberEntryOption

WithCommonServiceEntry provide CommonServiceEntry.

func WithDescription added in v0.0.5

func WithDescription(description string) FiberEntryOption

WithDescription provide name.

func WithDocsEntry added in v1.0.0

func WithDocsEntry(tvEntry *rkentry.DocsEntry) FiberEntryOption

WithDocsEntry provide DocsEntry.

func WithEventEntry added in v1.0.0

func WithEventEntry(eventLogger *rkentry.EventEntry) FiberEntryOption

WithEventEntry provide rkentry.EventEntry.

func WithFiberConfig added in v0.0.5

func WithFiberConfig(conf *fiber.Config) FiberEntryOption

WithFiberConfig provide fiber.Config.

func WithLoggerEntry added in v1.0.0

func WithLoggerEntry(zapLogger *rkentry.LoggerEntry) FiberEntryOption

WithLoggerEntry provide rkentry.LoggerEntry.

func WithMiddleware added in v1.0.0

func WithMiddleware(inters ...fiber.Handler) FiberEntryOption

WithMiddleware provide user interceptors.

func WithName added in v0.0.5

func WithName(name string) FiberEntryOption

WithName provide name.

func WithPProfEntry added in v1.1.0

func WithPProfEntry(p *rkentry.PProfEntry) FiberEntryOption

WithPProfEntry provide rkentry.PProfEntry.

func WithPort added in v0.0.5

func WithPort(port uint64) FiberEntryOption

WithPort provide port.

func WithPromEntry added in v0.0.5

func WithPromEntry(prom *rkentry.PromEntry) FiberEntryOption

WithPromEntry provide PromEntry.

func WithStaticFileHandlerEntry added in v0.0.5

func WithStaticFileHandlerEntry(staticEntry *rkentry.StaticFileHandlerEntry) FiberEntryOption

WithStaticFileHandlerEntry provide StaticFileHandlerEntry.

func WithSwEntry added in v0.0.5

func WithSwEntry(sw *rkentry.SWEntry) FiberEntryOption

WithSwEntry provide SwEntry.

Jump to

Keyboard shortcuts

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