commons

package
v1.2.85 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	GetCacheMod    = "get"
	GetSetCacheMod = "get-set"
	SetCacheMod    = "set"
	RemoveCacheMod = "remove"
)

Variables

This section is empty.

Functions

func NewFn

func NewFn[P any, R any](name string, handler FnHandler[P, R], options ...FnOption) services.Fn

Types

type Fn

type Fn[P any, R any] struct {
	// contains filtered or unexported fields
}

Fn builtin fn handler wrapper supported annotations @fn {name} @readonly @authorization @permission @validation @cache {get} {set} {get-set} {remove} {ttl} @cache-control {max-age=sec} {public=true} {must-revalidate} {proxy-revalidate} @barrier @metric @title {title} @description >>> {description} <<< @errors >>> {error_name} zh: {zh_message} en: {en_message} <<<

func (*Fn[P, R]) Handle

func (fn *Fn[P, R]) Handle(r services.Request) (v interface{}, err error)

func (*Fn[P, R]) Internal

func (fn *Fn[P, R]) Internal() bool

func (*Fn[P, R]) Name

func (fn *Fn[P, R]) Name() string

func (*Fn[P, R]) Readonly

func (fn *Fn[P, R]) Readonly() bool

type FnHandler

type FnHandler[P any, R any] func(ctx context.Context, param P) (v R, err error)

type FnOption added in v1.2.60

type FnOption func(opt *FnOptions) (err error)

func Authorization added in v1.2.60

func Authorization() FnOption

func Barrier added in v1.2.60

func Barrier() FnOption

func Cache added in v1.2.60

func Cache(mod string, param string) FnOption

func CacheControl added in v1.2.60

func CacheControl(maxAge int, public bool, mustRevalidate bool, proxyRevalidate bool) FnOption

func Deprecated added in v1.2.60

func Deprecated() FnOption

func Internal added in v1.2.60

func Internal() FnOption

func Metric added in v1.2.60

func Metric() FnOption

func Permission added in v1.2.60

func Permission() FnOption

func Readonly added in v1.2.60

func Readonly() FnOption

func Validation added in v1.2.60

func Validation(title string) FnOption

type FnOptions added in v1.2.60

type FnOptions struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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