main.go 503 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "os"
  6. "github.com/go-chi/chi/middleware"
  7. "github.com/qor5/admin/presets/examples"
  8. "gorm.io/driver/postgres"
  9. "gorm.io/gorm"
  10. "gorm.io/gorm/logger"
  11. )
  12. func main() {
  13. db, err := gorm.Open(postgres.Open(os.Getenv("DBString")), &gorm.Config{})
  14. if err != nil {
  15. panic(err)
  16. }
  17. db.Logger.LogMode(logger.Info)
  18. p := examples.Preset1(db)
  19. log.Println("serving on :7001")
  20. log.Fatal(http.ListenAndServe(":7001", middleware.Logger(
  21. middleware.RequestID(p))))
  22. }