middleware

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalhostOnly

func LocalhostOnly() gin.HandlerFunc

LocalhostOnly returns middleware that restricts access to loopback addresses.

func UsageMiddleware

func UsageMiddleware(usageStore *store.UsageStore) gin.HandlerFunc

UsageMiddleware records API usage statistics via a Gin middleware.

Types

type StreamUsageAccumulator added in v0.1.4

type StreamUsageAccumulator struct {
	Model        string
	InputTokens  int64
	OutputTokens int64
}

StreamUsageAccumulator accumulates token usage from SSE data lines.

func (*StreamUsageAccumulator) Sniff added in v0.1.4

func (a *StreamUsageAccumulator) Sniff(data string, format string)

Sniff parses a single SSE data line and accumulates usage fields.

Jump to

Keyboard shortcuts

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