Skip to content

Commit e4203c4

Browse files
committed
docs: improve code documentation and update test configurations
- Add detailed comments explaining the main function, including route configurations and logging behavior Signed-off-by: appleboy <[email protected]>
1 parent f8558bf commit e4203c4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

_example/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ import (
1616

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

19+
// main initializes the Gin router, sets up various routes with different logging
20+
// configurations, and starts the server on port 8080. The routes demonstrate
21+
// different ways to use the logger middleware, including logging all requests,
22+
// skipping certain paths, adding custom fields, and using JSON format logs.
23+
//
24+
// Routes:
25+
// - GET /pong: Logs request with default logger settings.
26+
// - GET /ping: Logs request with custom settings, including skipping paths and using UTC time.
27+
// - GET /skip: Logs request but skips logging for the /skip path.
28+
// - GET /regexp1: Logs request but skips logging for paths matching the provided regex.
29+
// - GET /regexp2: Logs request but skips logging for paths matching the provided regex.
30+
// - GET /id: Logs request with custom fields including trace ID, span ID, and a custom request ID.
31+
// - GET /json: Logs request in JSON format.
32+
// - GET /health: Skips logging for the /health path.
33+
// - GET /v1/ping: Skips logging for GET requests in the /v1 group.
34+
// - POST /v1/ping: Logs request for POST requests in the /v1 group.
35+
//
36+
// The server listens on 0.0.0.0:8080.
1937
func main() {
2038
r := gin.New()
2139

0 commit comments

Comments
 (0)