wext

package
v0.0.0-...-2e0c1f2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(a winter.App, installer Installer, altKeys ...string)

Install install a Installer

Types

type Extension

type Extension[OPTS any, INJ any] interface {
	// Instance create a instance of extension, one [winter.App] can have multiple instances
	Instance(altKeys ...string) Instance[OPTS, INJ]

	// Installer create [Installer]
	Installer(optFns ...func(opt *OPTS)) Installer

	// Default setup options by default
	Default(fn func(opt *OPTS)) Extension[OPTS, INJ]

	// Startup set startup function
	Startup(fn func(ctx context.Context, opt *OPTS) (inj INJ, err error)) Extension[OPTS, INJ]

	// Check set check func
	Check(fn func(ctx context.Context, inj INJ) (err error)) Extension[OPTS, INJ]

	// Middleware set middleware generation function
	Middleware(fn func(ins Instance[OPTS, INJ], opt *OPTS, inj *INJ) winter.MiddlewareFunc) Extension[OPTS, INJ]

	// Shutdown set the shutdown func
	Shutdown(fn func(ctx context.Context, inj INJ) (err error)) Extension[OPTS, INJ]
}

Extension a abstraction of extension for wboot application

func New

func New[OPTS any, INJ any](kind string) Extension[OPTS, INJ]

New create a new Extension with a kind and options generator

func Simple

func Simple[OPTS any](kind string) Extension[OPTS, *OPTS]

Simple create a new Extension with options injected

type Installer

type Installer interface {
	Install(a winter.App, altKeys ...string)
}

Installer simple interface wrapping an install method

type Instance

type Instance[OPTS any, INJ any] interface {
	// Set inject a value into [context.Context]
	Set(ctx context.Context, inj INJ) context.Context

	// Get get the value from [context.Context]
	Get(ctx context.Context) INJ
}

Instance an instance of an Extension

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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