rkmidmeta

package
v2.2.22 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 7 Imported by: 16

Documentation

Overview

Package rkmidmeta is a middleware for metadata

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeCtx

type BeforeCtx struct {
	Input struct {
		UrlPath string
		Request *http.Request
		Event   rkquery.Event
	}
	Output struct {
		RequestId       string
		HeadersToReturn map[string]string
	}
}

BeforeCtx context for Before() function

func NewBeforeCtx

func NewBeforeCtx() *BeforeCtx

NewBeforeCtx create new BeforeCtx with fields initialized

type BootConfig

type BootConfig struct {
	Enabled bool     `yaml:"enabled" json:"enabled"`
	Prefix  string   `yaml:"prefix" json:"prefix"`
	Ignore  []string `yaml:"ignore" json:"ignore"`
}

BootConfig for YAML

type Option

type Option func(*optionSet)

Option if for middleware options while creating middleware

func ToOptions

func ToOptions(config *BootConfig, entryName, entryType string) []Option

ToOptions convert BootConfig into Option list

func WithEntryNameAndType

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithMockOptionSet

func WithMockOptionSet(mock OptionSetInterface) Option

WithMockOptionSet provide mock OptionSetInterface

func WithPathToIgnore

func WithPathToIgnore(paths ...string) Option

WithPathToIgnore provide paths prefix that will ignore.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix provide prefix.

type OptionSetInterface

type OptionSetInterface interface {
	GetEntryName() string

	GetEntryType() string

	Before(*BeforeCtx)

	BeforeCtx(*http.Request, rkquery.Event) *BeforeCtx

	ShouldIgnore(string) bool
}

OptionSetInterface mainly for testing purpose

func NewOptionSet

func NewOptionSet(opts ...Option) OptionSetInterface

NewOptionSet Create new optionSet with options.

func NewOptionSetMock

func NewOptionSetMock(before *BeforeCtx) OptionSetInterface

NewOptionSetMock for testing purpose

Jump to

Keyboard shortcuts

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