admin

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartWebServer

func StartWebServer(data *Data) error

StartWebServer starts the HTTP service and listens for the admin requests

Types

type Auth added in v0.12.6

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

type Data

type Data struct {
	Port         int
	OneKeyGetter OneKeyRetriever
	LogProvider  LogProvider
	// logProvider       LogProvider
	UsageRestorer    UsageRestorer
	UsageReseter     UsageReseter
	ProjectValidator PrValidator
	Auth             echo.MiddlewareFunc
	Hasher           Hasher

	CmsData *cms.Data
}

Data is service operation data

type Hasher added in v0.12.6

type Hasher interface {
	HashKey(key string) string
}

type LogProvider

type LogProvider interface {
	GetLogs(ctx context.Context, user *model.User, keyID string) ([]*adminapi.Log, error)
	ListLogs(ctx context.Context, project string, to time.Time) ([]*adminapi.Log, error)
	DeleteLogs(ctx context.Context, project string, to time.Time) (int, error)
}

LogRetriever retrieves one list from db

type OneKeyRetriever

type OneKeyRetriever interface {
	Get(ctx context.Context, user *model.User, id string) (*adminapi.Key, error)
}

type PrValidator

type PrValidator interface {
	Check(string) bool
	Projects() []string
}

PrValidator validates if project is available

type ProjectConfigValidator

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

ProjectConfigValidator loads available projects from config

func NewProjectConfigValidator

func NewProjectConfigValidator(projects string) (*ProjectConfigValidator, error)

NewProjectConfigValidator creates project validator, reads available projects from config

func (*ProjectConfigValidator) Check

func (pv *ProjectConfigValidator) Check(pr string) bool

Check tests if project is available

func (*ProjectConfigValidator) Projects

func (pv *ProjectConfigValidator) Projects() []string

Projects returns all supported projects

type UsageReseter

type UsageReseter interface {
	Reset(ctx context.Context, project string, since time.Time, limit float64) error
}

UsageReseter resets montly usage

type UsageRestorer

type UsageRestorer interface {
	RestoreUsage(ctx context.Context, project string, manual bool, request string, errorMsg string) error

} // OneKeyRetriever retrieves one list from db

UsageRestorer restores key usage by requestID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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