wrapper.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package wrapper
  2. import (
  3. "database/sql"
  4. "net/http"
  5. "golang-fave/logger"
  6. _ "github.com/go-sql-driver/mysql"
  7. "github.com/vladimirok5959/golang-server-sessions/session"
  8. )
  9. type Wrapper struct {
  10. l *logger.Logger
  11. W http.ResponseWriter
  12. R *http.Request
  13. S *session.Session
  14. Host string
  15. Port string
  16. DConfig string
  17. DHtdocs string
  18. DLogs string
  19. DTemplate string
  20. DTmp string
  21. IsBackend bool
  22. ConfMysqlExists bool
  23. DB *sql.DB
  24. }
  25. func New(l *logger.Logger, w http.ResponseWriter, r *http.Request, s *session.Session, host, port, dirConfig, dirHtdocs, dirLogs, dirTemplate, dirTmp string) *Wrapper {
  26. return &Wrapper{
  27. l: l,
  28. W: w,
  29. R: r,
  30. S: s,
  31. Host: host,
  32. Port: port,
  33. DConfig: dirConfig,
  34. DHtdocs: dirHtdocs,
  35. DLogs: dirLogs,
  36. DTemplate: dirTemplate,
  37. DTmp: dirTmp,
  38. }
  39. }
  40. func (this *Wrapper) LogAccess(msg string) {
  41. this.l.Log(msg, this.R, false)
  42. }
  43. func (this *Wrapper) LogError(msg string) {
  44. this.l.Log(msg, this.R, true)
  45. }