controller.go 721 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package controller
  2. import (
  3. "io"
  4. "io/fs"
  5. "os"
  6. "git.aetherial.dev/aeth/keiji/pkg/auth"
  7. "git.aetherial.dev/aeth/keiji/pkg/storage"
  8. )
  9. type Controller struct {
  10. Domain string
  11. database storage.DocumentIO
  12. Cache *auth.AuthCache
  13. AuthSource auth.Source
  14. FileIO fs.FS
  15. log io.Writer
  16. }
  17. func NewController(domain string, database storage.DocumentIO, files fs.FS, authSrc auth.Source) *Controller {
  18. return &Controller{
  19. Cache: auth.NewCache(),
  20. AuthSource: authSrc,
  21. Domain: domain,
  22. database: database,
  23. FileIO: files,
  24. log: os.Stdout,
  25. }
  26. }
  27. func (c Controller) LogMsg(msg ...string) {
  28. for i := range msg {
  29. c.log.Write([]byte(msg[i]))
  30. }
  31. c.log.Write([]byte("\n"))
  32. }