Initial commit 3.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Logger is a simple request logger middleware
|
||||
func Logger() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
start := time.Now()
|
||||
c.Next()
|
||||
log.Printf("%s %s %d %s", c.Request.Method, c.Request.URL.Path, c.Writer.Status(), time.Since(start))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add more middleware (e.g., CORS, Auth) as needed
|
||||
Reference in New Issue
Block a user