middleware

package
v3.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(NewMiddlewares)

Functions

func Abort

func Abort(w http.ResponseWriter, code int, format string, args ...any)

func Entrance

func Entrance(t *gotext.Locale, conf *config.Config, session *sessions.Manager) func(next http.Handler) http.Handler

Entrance 确保通过正确的入口访问

func MustInstall

func MustInstall(t *gotext.Locale, app biz.AppRepo) func(next http.Handler) http.Handler

MustInstall 确保已安装应用

func MustLogin

func MustLogin(t *gotext.Locale, conf *config.Config, session *sessions.Manager, userToken biz.UserTokenRepo) func(next http.Handler) http.Handler

MustLogin 确保已登录

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer 捕获 panic,记录日志并返回 JSON 错误响应

func Status

func Status(t *gotext.Locale) func(next http.Handler) http.Handler

Status 检查程序状态

func Throttle

func Throttle(ipHeader string, tokens uint64, interval time.Duration) func(next http.Handler) http.Handler

Throttle 限流器

Types

type Middlewares

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

func NewMiddlewares

func NewMiddlewares(conf *config.Config, session *sessions.Manager, appRepo biz.AppRepo, userToken biz.UserTokenRepo) *Middlewares

func (*Middlewares) Globals

func (r *Middlewares) Globals(t *gotext.Locale, mux *chi.Mux) []func(http.Handler) http.Handler

Globals is a collection of global middleware that will be applied to every request.

Jump to

Keyboard shortcuts

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