feat(keys): allow to set api keys to secure the instance (#39)

This commit is contained in:
Ettore Di Giacinto
2025-03-11 23:14:05 +01:00
committed by GitHub
parent 1e484d7ccd
commit 0ad2de72e0
7 changed files with 297 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import "github.com/mudler/LocalAgent/core/state"
type Config struct {
DefaultChunkSize int
Pool *state.AgentPool
ApiKeys []string
}
type Option func(*Config)
@@ -21,6 +22,12 @@ func WithPool(pool *state.AgentPool) Option {
}
}
func WithApiKeys(keys ...string) Option {
return func(c *Config) {
c.ApiKeys = keys
}
}
func (c *Config) Apply(opts ...Option) {
for _, opt := range opts {
opt(c)