add log middleware (just for testing)
This commit is contained in:
+10
-9
@@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
@@ -11,15 +11,16 @@ import (
|
||||
func main() {
|
||||
connectDB()
|
||||
|
||||
r := chi.NewRouter()
|
||||
router := chi.NewRouter()
|
||||
|
||||
r.Use(authMiddleware)
|
||||
router.Use(logMiddleware)
|
||||
router.Use(authMiddleware)
|
||||
|
||||
// routes
|
||||
r.Get("/quotes", getQuotes)
|
||||
r.Post("/quotes", createQuote)
|
||||
r.Put("/quotes/{id}", updateQuote)
|
||||
r.Delete("/quotes/{id}", deleteQuote)
|
||||
router.Get("/quotes", getQuotes)
|
||||
router.Post("/quotes", createQuote)
|
||||
router.Put("/quotes/{id}", updateQuote)
|
||||
router.Delete("/quotes/{id}", deleteQuote)
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
@@ -27,5 +28,5 @@ func main() {
|
||||
}
|
||||
|
||||
fmt.Println("started and listening on localhost:" + port)
|
||||
http.ListenAndServe(":"+port, r)
|
||||
}
|
||||
http.ListenAndServe(":"+port, router)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user