Files
ai-agent/agentdesk.go
T

37 lines
1005 B
Go
Raw Normal View History

package agentdesk
import (
"errors"
"net/http"
"code.tczkiot.com/wlw/ai-agent/identity"
"code.tczkiot.com/wlw/ai-agent/internal/bootstrap"
"code.tczkiot.com/wlw/ai-agent/internal/services"
)
type Options struct {
ConfigPath string
QuerySubjects identity.QuerySubjectsFunc
Authorize identity.AuthorizeFunc
}
// New initializes the customer-service business module. Authentication and
// authorization must already have been completed by the host system.
func New(options Options) (http.Handler, error) {
if options.QuerySubjects == nil {
return nil, errors.New("agent-desk: QuerySubjects is required")
}
if options.Authorize == nil {
return nil, errors.New("agent-desk: Authorize is required")
}
if options.ConfigPath == "" {
options.ConfigPath = "config/config.yaml"
}
services.SetQuerySubjects(options.QuerySubjects)
services.SetAuthorize(options.Authorize)
if err := bootstrap.Init(options.ConfigPath); err != nil {
return nil, err
}
return bootstrap.NewServer()
}