Skip to content

Commit a5b1578

Browse files
Merge pull request #281 from gabriel-samfira/cleanup-websocket-urls
Rename websocket URLs
2 parents 7fe2a3a + 79c1e47 commit a5b1578

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

apiserver/routers/routers.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,18 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
411411
apiRouter.Handle("/github/credentials/{id}/", http.HandlerFunc(han.UpdateGithubCredential)).Methods("PUT", "OPTIONS")
412412
apiRouter.Handle("/github/credentials/{id}", http.HandlerFunc(han.UpdateGithubCredential)).Methods("PUT", "OPTIONS")
413413

414-
// Websocket log writer
415-
apiRouter.Handle("/{ws:ws\\/?}", http.HandlerFunc(han.WSHandler)).Methods("GET")
416-
apiRouter.Handle("/{events:events\\/?}", http.HandlerFunc(han.EventsHandler)).Methods("GET")
414+
/////////////////////////
415+
// Websocket endpoints //
416+
/////////////////////////
417+
// Legacy log websocket path
418+
apiRouter.Handle("/ws/", http.HandlerFunc(han.WSHandler)).Methods("GET")
419+
apiRouter.Handle("/ws", http.HandlerFunc(han.WSHandler)).Methods("GET")
420+
// Log websocket endpoint
421+
apiRouter.Handle("/ws/logs/", http.HandlerFunc(han.WSHandler)).Methods("GET")
422+
apiRouter.Handle("/ws/logs", http.HandlerFunc(han.WSHandler)).Methods("GET")
423+
// DB watcher websocket endpoint
424+
apiRouter.Handle("/ws/events/", http.HandlerFunc(han.EventsHandler)).Methods("GET")
425+
apiRouter.Handle("/ws/events", http.HandlerFunc(han.EventsHandler)).Methods("GET")
417426

418427
// NotFound handler
419428
apiRouter.PathPrefix("/").HandlerFunc(han.NotFoundHandler).Methods("GET", "POST", "PUT", "DELETE", "OPTIONS")

cmd/garm-cli/cmd/events.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var eventsCmd = &cobra.Command{
2727
ctx, stop := signal.NotifyContext(context.Background(), signals...)
2828
defer stop()
2929

30-
reader, err := garmWs.NewReader(ctx, mgr.BaseURL, "/api/v1/events", mgr.Token, common.PrintWebsocketMessage)
30+
reader, err := garmWs.NewReader(ctx, mgr.BaseURL, "/api/v1/ws/events", mgr.Token, common.PrintWebsocketMessage)
3131
if err != nil {
3232
return err
3333
}

cmd/garm-cli/cmd/log.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var logCmd = &cobra.Command{
2121
ctx, stop := signal.NotifyContext(context.Background(), signals...)
2222
defer stop()
2323

24-
reader, err := garmWs.NewReader(ctx, mgr.BaseURL, "/api/v1/ws", mgr.Token, common.PrintWebsocketMessage)
24+
reader, err := garmWs.NewReader(ctx, mgr.BaseURL, "/api/v1/ws/logs", mgr.Token, common.PrintWebsocketMessage)
2525
if err != nil {
2626
return err
2727
}

0 commit comments

Comments
 (0)