Documentation
¶
Overview ¶
Package devtools serves gin-kit's development dashboard: a request log, mail outbox, route list, redacted config report, and queue statistics behind a single mount point. It is strictly a development tool — the runtime refuses to enable it outside the development environment — and its request log deliberately stores no bodies, no query strings, and no headers beyond the user agent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigEntry ¶
type ConfigEntry struct {
// Key store data used by this type.
Key string `json:"key"`
// Value store data used by this type.
Value string `json:"value"`
// Redacted store data used by this type.
Redacted bool `json:"redacted"`
}
ConfigEntry is one environment variable in the devtools config report.
type DevTools ¶
type DevTools struct {
// contains filtered or unexported fields
}
DevTools records requests and mail and serves the dashboard over them.
func (*DevTools) Middleware ¶
func (d *DevTools) Middleware() gin.HandlerFunc
Middleware records completed requests into the devtools log. Requests to the dashboard itself are skipped so polling does not flood the log. Only the URL path is stored — never the query string, bodies, or headers other than the user agent.
func (*DevTools) Mount ¶
func (d *DevTools) Mount(router gin.IRouter, routes func() gin.RoutesInfo, queueStats func(context.Context) (queue.Stats, error))
Mount registers the dashboard page and its JSON API on router under the configured path. routes and queueStats supply live data at request time; either may be nil, which renders an empty tab.
type MailEntry ¶
type MailEntry struct {
// ID store data used by this type.
ID int64 `json:"id"`
// Time store data used by this type.
Time time.Time `json:"time"`
Status string `json:"status"` // "sent" or "failed"
// Error store data used by this type.
Error string `json:"error,omitempty"`
mail.Envelope
}
MailEntry is one message captured by the devtools outbox, successful or not. The embedded envelope carries metadata and bodies; attachment content is never captured.
type Options ¶
type Options struct {
// Path is the dashboard mount point, defaulting to /_ginkit.
Path string
// Logger defaults to slog.Default().
Logger *slog.Logger
// Mapper derives the public error code recorded for failed requests,
// exactly like the runtime error handler does. It defaults to
// httpx.DefaultMapper.
Mapper httpx.Mapper
// MaxEntries caps the request log, defaulting to 200.
MaxEntries int
// MaxMails caps the mail outbox, defaulting to 50.
MaxMails int
}
Options defines an implementation type used by this package.
type RequestEntry ¶
type RequestEntry struct {
// ID store data used by this type.
ID int64 `json:"id"`
// Time store data used by this type.
Time time.Time `json:"time"`
// Method store data used by this type.
Method string `json:"method"`
// Path store data used by this type.
Path string `json:"path"`
// Status store data used by this type.
Status int `json:"status"`
// DurationMS store data used by this type.
DurationMS int64 `json:"duration_ms"`
// RequestID store data used by this type.
RequestID string `json:"request_id"`
// ClientIP store data used by this type.
ClientIP string `json:"client_ip"`
// UserAgent store data used by this type.
UserAgent string `json:"user_agent"`
// ErrorCode store data used by this type.
ErrorCode string `json:"error_code,omitempty"`
}
RequestEntry is one completed request in the devtools log. It deliberately stores no request or response bodies, no headers beyond the user agent, and never the query string.
type RouteEntry ¶
type RouteEntry struct {
// Method store data used by this type.
Method string `json:"method"`
// Path store data used by this type.
Path string `json:"path"`
// Handler store data used by this type.
Handler string `json:"handler"`
}
RouteEntry is one registered route in the devtools route list.