main.go 496 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "os"
  6. "github.com/go-chi/chi/v5/middleware"
  7. "github.com/qor5/admin/example/admin"
  8. )
  9. func main() {
  10. h := admin.Router()
  11. port := os.Getenv("PORT")
  12. if len(port) == 0 {
  13. port = "9000"
  14. }
  15. fmt.Println("Served at http://localhost:" + port)
  16. mux := http.NewServeMux()
  17. mux.Handle("/",
  18. middleware.RequestID(
  19. middleware.Logger(
  20. middleware.Recoverer(h),
  21. ),
  22. ),
  23. )
  24. err := http.ListenAndServe(":"+port, mux)
  25. if err != nil {
  26. panic(err)
  27. }
  28. }