Skip to content

Commit

Permalink
Added get uid error control
Browse files Browse the repository at this point in the history
  • Loading branch information
catttam committed Sep 16, 2024
1 parent ff1a27c commit a73c247
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ func main() {
clientIP := c.ClientIP()
method := c.Request.Method
path := c.Request.URL.Path
user, _ := c.Get("uidOrigin")

uidOrigin, _ := c.Get("uidOrigin")
user, uidParsed := uidOrigin.(string)
if !uidParsed {
user = "nil"
}
// Example of logging custom information
log.Printf("[Custom Middleware] %v | %3d | %13v | %s | %-7s %#v\n | %s",
time.Now().Format(time.RFC3339), status, latency, clientIP, method, path, user.(string))
log.Printf("[Gin logger] %v | %3d | %13v | %s | %-7s %#v\n | %s",
time.Now().Format(time.RFC3339), status, latency, clientIP, method, path, user)
})

// Config path
Expand Down

0 comments on commit a73c247

Please sign in to comment.