Skip to content

Commit

Permalink
Testing gin custom logger and auth on invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
catttam committed Sep 18, 2024
1 parent a73c247 commit 116fba7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ func main() {
r.Use(func(c *gin.Context) {
start := time.Now()

// Process request
c.Next()

// Log custom information after the request is processed
latency := time.Since(start)
status := c.Writer.Status()
Expand All @@ -107,6 +104,9 @@ func main() {
// Example of logging custom information
log.Printf("[Gin logger] %v | %3d | %13v | %s | %-7s %#v\n | %s",
time.Now().Format(time.RFC3339), status, latency, clientIP, method, path, user)

// Process request
c.Next()
})

// Config path
Expand Down
12 changes: 7 additions & 5 deletions pkg/handlers/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ func MakeRunHandler(cfg *types.Config, back types.SyncBackend) gin.HandlerFunc {
c.Status(http.StatusUnauthorized)
return
}
reqToken := strings.TrimSpace(splitToken[1])
if reqToken != service.Token {
c.Status(http.StatusUnauthorized)
return
}

// OLD: Using service token to authenticate
// reqToken := strings.TrimSpace(splitToken[1])
// if reqToken != service.Token {
// c.Status(http.StatusUnauthorized)
// return
// }

proxy := &httputil.ReverseProxy{
Director: back.GetProxyDirector(service.Name),
Expand Down

0 comments on commit 116fba7

Please sign in to comment.