handler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AudioLenQuota

func AudioLenQuota(next http.Handler, field string, srv AudioLenGetter) http.Handler

AudioLenQuota creates handler

func CleanHeader

func CleanHeader(next http.Handler, starting string) (http.Handler, error)

CleanHeader removes header with key names starting with 'starting' from request

func FillHeader

func FillHeader(next http.Handler) http.Handler

FillHeader creates handler for filling header values from tags

func FillKeyHeader

func FillKeyHeader(next http.Handler) http.Handler

FillKeyHeader creates handler for adding key hash value into "x-tts-save-tags"

func FillOutHeader

func FillOutHeader(next http.Handler) http.Handler

FillOutHeader creates handler for filling header out values from tags starting with x-header-out:

func FillRequestIDHeader

func FillRequestIDHeader(next http.Handler, dbName string) http.Handler

FillRequestIDHeader creates handler for adding requestID into header x-doorman-requestid"

func GetInfo

func GetInfo(pr string, h interface{}) string

GetInfo return info if handler has one

func IPAsKey

func IPAsKey(next http.Handler, ipSaver IPSaver) http.Handler

IPAsKey creates handler

func JSONAsQuota

func JSONAsQuota(next http.Handler) http.Handler

JSONAsQuota creates handler

func JSONTTSAsQuota

func JSONTTSAsQuota(next http.Handler, discount float64) (http.Handler, error)

JSONTTSAsQuota creates handler

func KeyExtract

func KeyExtract(next http.Handler) http.Handler

KeyExtract creates handler

func KeyValid

func KeyValid(next http.Handler, kv KeyValidator) http.Handler

KeyValid creates handler

func KeyValidOrIP

func KeyValidOrIP(withKeyHandler http.Handler, withIPHandler http.Handler) http.Handler

KeyValidOrIP creates handler

func LogDB

func LogDB(next http.Handler, dbs DBSaver, syncLog bool) http.Handler

LogDB creates handler

func LogShitf

func LogShitf(str string) string

LogShitf appends spaces to strin

func LogStdout

func LogStdout(next http.Handler) http.Handler

LogStdout creates handler

func Proxy

func Proxy(url *url.URL) http.Handler

Proxy creates handler

func QuotaValidate

func QuotaValidate(next http.Handler, qv QuotaValidator) http.Handler

QuotaValidate creates handler

func RateLimitValidate added in v0.11.0

func RateLimitValidate(next http.Handler, qv RateLimitValidator, limit int64) http.Handler

QuotaValidate creates handler

func RequestAsQuota

func RequestAsQuota(next http.Handler) http.Handler

RequestAsQuota creates handler

func SkipFirstQuota

func SkipFirstQuota(next http.Handler, cg CountGetter) http.Handler

SkipFirstQuota creates handler

func StripPrefix

func StripPrefix(next http.Handler, prefix string) http.Handler

StripPrefix creates handler

func TakeJSON

func TakeJSON(next http.Handler, field string) http.Handler

TakeJSON creates handler

func TakeJSONTTS

func TakeJSONTTS(next http.Handler) http.Handler

TakeJSONTTS creates handler

func ToTextAndQuota

func ToTextAndQuota(next http.Handler, field string, srv TextGetter) http.Handler

ToTextAndQuota creates handler. The handler: - extracts file from form field, - converts file to txt, - packs text as file into new request

Types

type AudioLenGetter

type AudioLenGetter interface {
	Get(name string, file io.Reader) (float64, error)
}

AudioLenGetter get duration

type Auth added in v1.0.0

type Auth interface {
	ValidateToken(ctx context.Context, token string) (*model.User, error)
}

type AuthMiddleware added in v1.0.0

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

func NewAuthMiddleware added in v1.0.0

func NewAuthMiddleware(auth Auth) (*AuthMiddleware, error)

func (*AuthMiddleware) Handle added in v1.0.0

func (a *AuthMiddleware) Handle(next echo.HandlerFunc) echo.HandlerFunc

Handle is the method that implements the middleware logic

type CountGetter

type CountGetter interface {
	Get(id string) (int64, error)
	GetParamName() string
}

CountGetter get usage count from external system

type DBSaver

type DBSaver interface {
	SaveLog(ctx context.Context, data *api.Log) error
}

DBSaver logs to db

type IPSaver

type IPSaver interface {
	Save(ctx context.Context, ip string) (string, error)
}

IPSaver saves ip a=as key into DB

type KeyValidator

type KeyValidator interface {
	IsValid(context.Context, string, string, bool) (bool, string, []string, error)
}

KeyValidator validator

type QuotaValidator

type QuotaValidator interface {
	SaveValidate(ctx context.Context, key string, ip string, manual bool, quota float64) (bool, float64, float64, error)
	Restore(ctx context.Context, key string, manual bool, quota float64) (float64, float64, error)
}

QuotaValidator validator

type RateLimitValidator added in v0.11.0

type RateLimitValidator interface {
	Validate(string, int64, int64) (bool, int64, int64, error)
}

RateLimit validator

type TextGetter

type TextGetter interface {
	Get(name string, file io.Reader) (string, error)
}

TextGetter get duration

Jump to

Keyboard shortcuts

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