@@ -44,7 +44,7 @@ func pipe_std_ws_server(config ConfigServer, credentialdb *gorm.DB, tokendb *gor
4444 // authHandler := AuthorizationHandler(credentialdb, tokendb)
4545 var routes []RouteConfig //{
4646
47- handlerGet := createhandlerauthorization (credentialdb , tokendb , func (w context.Context , r * app.RequestContext ) {
47+ handlerGetWebsocket := createhandlerauthorization (credentialdb , tokendb , func (w context.Context , r * app.RequestContext ) {
4848
4949 sessions , err := ReadAllSessions (sessiondb )
5050 if err != nil {
@@ -108,7 +108,7 @@ func pipe_std_ws_server(config ConfigServer, credentialdb *gorm.DB, tokendb *gor
108108 Connection := strings .ToLower (r .Request .Header .Get ("Connection" ))
109109
110110 if string (r .Method ()) == consts .MethodGet && strings .Contains (Connection , "upgrade" ) && Upgrade == "websocket" {
111- handlerGet (w , r )
111+ handlerGetWebsocket (w , r )
112112 return
113113 }
114114
@@ -132,25 +132,8 @@ func pipe_std_ws_server(config ConfigServer, credentialdb *gorm.DB, tokendb *gor
132132 middlewares := []app.HandlerFunc {
133133
134134 func (c context.Context , ctx * app.RequestContext ) {
135- routesmiddle := MatchAndRouteMiddleware ([]RouteConfig {
136-
137- {
138- Path : "/sessions" ,
139- Method : "COPY" ,
140- MiddleWare : HertzCompose (AuthorizationMiddleware (credentialdb , tokendb , sessiondb ), func (c context.Context , r * app.RequestContext , next HertzNext ) {
141- CopyMiddleware (credentialdb , tokendb , sessiondb , c , r , next )
142-
143- }),
144- },
145- {
146- Path : "/sessions" ,
147- Method : "MOVE" ,
148- MiddleWare : HertzCompose (AuthorizationMiddleware (credentialdb , tokendb , sessiondb ), func (c context.Context , r * app.RequestContext , next HertzNext ) {
149- MoveMiddleware (initial_sessions , credentialdb , tokendb , sessiondb , c , r , next )
150-
151- }),
152- },
153- })
135+ routes_copy_and_move := GenerateRoutesHttpsessions (credentialdb , tokendb , sessiondb , initial_sessions )
136+ routesmiddle := MatchAndRouteMiddleware (routes_copy_and_move )
154137 routesmiddle (c , ctx , func (c context.Context , r * app.RequestContext ) {
155138 r .Next (c )
156139 })
0 commit comments