diff --git a/internal/handler/subscribe.go b/internal/handler/subscribe.go index 4751be6..9cb82b6 100644 --- a/internal/handler/subscribe.go +++ b/internal/handler/subscribe.go @@ -45,6 +45,7 @@ func SubscribeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { l := subscribe.NewSubscribeLogic(c, svcCtx) resp, err := l.Handler(&req) if err != nil { + c.String(http.StatusInternalServerError, "Internal Server") return } c.Header("subscription-userinfo", resp.Header) diff --git a/internal/middleware/loggerMiddleware.go b/internal/middleware/loggerMiddleware.go index 43e27ab..7bb2def 100644 --- a/internal/middleware/loggerMiddleware.go +++ b/internal/middleware/loggerMiddleware.go @@ -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) + } } } diff --git a/internal/middleware/panDomainMiddleware.go b/internal/middleware/panDomainMiddleware.go index 576ff59..1bc590e 100644 --- a/internal/middleware/panDomainMiddleware.go +++ b/internal/middleware/panDomainMiddleware.go @@ -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")