Commit 9618b19f authored by qiuqunfeng's avatar qiuqunfeng
Browse files

Refactor import statements in cmd.go and app.go for improved organization; add...

Refactor import statements in cmd.go and app.go for improved organization; add logging in WafLogController for better traceability of proxy requests.
parent cfb942a8
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"gitlab.com/tensorsecurity-rd/waf-console/cmd/api-server/config" "gitlab.com/tensorsecurity-rd/waf-console/cmd/api-server/config"
// "gitlab.com/tensorsecurity-rd/waf-console/cmd/config" // "gitlab.com/tensorsecurity-rd/waf-console/cmd/config"
"gitlab.com/tensorsecurity-rd/waf-console/internal/service" "gitlab.com/tensorsecurity-rd/waf-console/internal/service"
es "gitlab.com/tensorsecurity-rd/waf-console/internal/store" es "gitlab.com/tensorsecurity-rd/waf-console/internal/store"
) )
......
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitlab.com/tensorsecurity-rd/waf-console/api" "gitlab.com/tensorsecurity-rd/waf-console/api"
"gitlab.com/tensorsecurity-rd/waf-console/cmd/config" "gitlab.com/tensorsecurity-rd/waf-console/cmd/config"
"gitlab.com/tensorsecurity-rd/waf-console/internal/service"
es "gitlab.com/tensorsecurity-rd/waf-console/internal/store" es "gitlab.com/tensorsecurity-rd/waf-console/internal/store"
"gitlab.com/tensorsecurity-rd/waf-console/internal/utils" "gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
...@@ -86,8 +85,8 @@ func NewRootCommand() *cobra.Command { ...@@ -86,8 +85,8 @@ func NewRootCommand() *cobra.Command {
ESTimeout: 10 * time.Second, ESTimeout: 10 * time.Second,
}, esClient) }, esClient)
esStore.Init() esStore.Init()
logConsumerService := service.NewLogConsumerService(db, esStore, config.KafkaConfig) // logConsumerService := service.NewLogConsumerService(db, esStore, config.KafkaConfig)
go logConsumerService.Consume() // go logConsumerService.Consume()
return e.Run(":8080") return e.Run(":8080")
}, },
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
) )
type WafLogController struct { type WafLogController struct {
...@@ -27,6 +28,7 @@ func (c *WafLogController) WafLogProxy(ctx *gin.Context) { ...@@ -27,6 +28,7 @@ func (c *WafLogController) WafLogProxy(ctx *gin.Context) {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return return
} }
log.Info().Msgf("remoteUrl: %s", remoteUrl.String())
proxy := httputil.NewSingleHostReverseProxy(remoteUrl) proxy := httputil.NewSingleHostReverseProxy(remoteUrl)
proxy.Director = func(req *http.Request) { proxy.Director = func(req *http.Request) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment