handler

package
v0.10.10 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CtxContext context key for custom context object
	CtxContext key = iota
)

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) 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 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 CountGetter

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

CountGetter get usage count from external system

type DBSaver

type DBSaver interface {
	Save(*api.Log) error
}

DBSaver logs to db

type IPSaver

type IPSaver interface {
	Save(string) error
}

IPSaver saves ip a=as key into DB

type KeyValidator

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

KeyValidator validator

type QuotaValidator

type QuotaValidator interface {
	SaveValidate(string, string, bool, float64) (bool, float64, float64, error)
	Restore(string, bool, float64) (float64, float64, error)
}

QuotaValidator 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