diff --git a/assembly/assembly.go b/assembly/assembly.go index ce76eaf..68df105 100644 --- a/assembly/assembly.go +++ b/assembly/assembly.go @@ -50,7 +50,7 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) { return nil, errors.WithMessage(err, "new grpc client") } grpcClientByModuleName[location.TargetModule] = cli - case conf.HttpProtocol: + case conf.HttpProtocol, conf.WsProtocol: rb := lb.NewRoundRobin(nil) httpHostManagerByModuleName[location.TargetModule] = rb default: diff --git a/assembly/locator.go b/assembly/locator.go index 7394814..96d97ec 100644 --- a/assembly/locator.go +++ b/assembly/locator.go @@ -64,6 +64,8 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli throttlingRepo := repository.NewThrottling(redisCli) throttlingService := service.NewThrottling(throttlingRepo, config.Throttling) + enableBodyLog := config.Logging.BodyLogEnable + mux := http.NewServeMux() for _, location := range locations { var proxyFunc middleware.Handler @@ -74,6 +76,10 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli case conf.HttpProtocol: hostManager := l.httpHostManagerByModuleName[location.TargetModule] proxyFunc = proxy.NewHttp(hostManager, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second) + case conf.WsProtocol: + hostManager := l.httpHostManagerByModuleName[location.TargetModule] + proxyFunc = proxy.NewWs(hostManager, location.SkipAuth) + enableBodyLog = false default: return nil, errors.Errorf("not supported protocol %s", location.Protocol) } @@ -81,7 +87,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli handler := middleware.Chain( proxyFunc, middleware.RequestId(), - middleware.Logger(l.logger, config.Logging.RequestLogEnable, config.Logging.BodyLogEnable), + middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog), middleware.ErrorHandler(l.logger), middleware.Authenticate(authentication), middleware.AdminAuthenticate(adminService), @@ -94,7 +100,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli handler = middleware.Chain( proxyFunc, middleware.RequestId(), - middleware.Logger(l.logger, config.Logging.RequestLogEnable, config.Logging.BodyLogEnable), + middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog), middleware.ErrorHandler(l.logger), ) }