Skip to content

Commit

Permalink
docs: improve code documentation and update test configurations
Browse files Browse the repository at this point in the history
- Add detailed comments explaining the main function, including route configurations and logging behavior

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Nov 8, 2024
1 parent f8558bf commit e4203c4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ import (

var rxURL = regexp.MustCompile(`^/regexp\d*`)

// main initializes the Gin router, sets up various routes with different logging
// configurations, and starts the server on port 8080. The routes demonstrate
// different ways to use the logger middleware, including logging all requests,
// skipping certain paths, adding custom fields, and using JSON format logs.
//
// Routes:
// - GET /pong: Logs request with default logger settings.
// - GET /ping: Logs request with custom settings, including skipping paths and using UTC time.
// - GET /skip: Logs request but skips logging for the /skip path.
// - GET /regexp1: Logs request but skips logging for paths matching the provided regex.
// - GET /regexp2: Logs request but skips logging for paths matching the provided regex.
// - GET /id: Logs request with custom fields including trace ID, span ID, and a custom request ID.
// - GET /json: Logs request in JSON format.
// - GET /health: Skips logging for the /health path.
// - GET /v1/ping: Skips logging for GET requests in the /v1 group.
// - POST /v1/ping: Logs request for POST requests in the /v1 group.
//
// The server listens on 0.0.0.0:8080.
func main() {
r := gin.New()

Expand Down

0 comments on commit e4203c4

Please sign in to comment.