APIKeyOpts
Overview
APIKeyOpts configures API key middleware.
Part of the auth package — Node.js analog: passport.
APIKeyOpts is a type exported by gox. Methods on this type are documented separately.
Signature
go
type APIKeyOpts struct {
Keys map[string]bool
Validate func(key string) bool
}Compare: Node.js · Standard Go · gox
js
// Typical passport pattern in Node.jsgo
// net/http middleware checking Authorization headergo
import "github.com/sahilkhaire/gox/auth"
opts := auth.APIKeyOpts{Keys: map[string]bool{"secret-key": true}}Example
go
import "github.com/sahilkhaire/gox/auth"
opts := auth.APIKeyOpts{Keys: map[string]bool{"secret-key": true}}Tips
Browse methods on this type in the sidebar for handler-style APIs and options structs.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.