fix(subscribe): improve error handling and logging for subscription requests

This commit is contained in:
Chang lue Tsen
2025-08-17 10:01:12 -04:00
parent 6580cc9d44
commit 5d80d95568
3 changed files with 9 additions and 2 deletions
+8 -1
View File
@@ -44,6 +44,9 @@ func LoggerMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
// Start recording logs
cost := time.Since(start)
responseStatus := c.Writer.Status()
host := c.Request.Host
logs := []logger.LogField{
{
Key: "status",
@@ -51,7 +54,7 @@ func LoggerMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
},
{
Key: "request",
Value: c.Request.Method + " " + c.Request.URL.String(),
Value: c.Request.Method + " " + host + c.Request.URL.String(),
},
{
Key: "query",
@@ -88,6 +91,10 @@ func LoggerMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
} else {
logger.WithContext(c.Request.Context()).Infow("HTTP Request", logs...)
}
if responseStatus == 404 {
logger.WithContext(c.Request.Context()).Debugf("404 Not Found: Host:%s Path:%s IsPanDomain:%v", host, c.Request.URL.Path, svc.Config.Subscribe.PanDomain)
}
}
}
@@ -14,7 +14,6 @@ func PanDomainMiddleware(svc *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
if svc.Config.Subscribe.PanDomain && c.Request.URL.Path == "/" {
// intercept browser
ua := c.GetHeader("User-Agent")