main.go 473 B

12345678910111213141516171819202122232425262728293031
  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. mux := 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. http.Handle("/",
  17. middleware.RequestID(
  18. middleware.Logger(
  19. middleware.Recoverer(mux),
  20. ),
  21. ),
  22. )
  23. err := http.ListenAndServe(":"+port, nil)
  24. if err != nil {
  25. panic(err)
  26. }
  27. }