Skip to content

Commit 640e644

Browse files
committed
refactor: rename variable 'h' to 'hub' for clarity in main.go and update related references
1 parent d2d3aa6 commit 640e644

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

main.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ func loop(stray *systray.Systray, configPath *paths.Path) {
196196

197197
// var loggerWs logWriter
198198

199-
h := NewHub(serialHub, serialPorts)
199+
hub := NewHub(serialHub, serialPorts)
200200

201201
logger := func(msg string) {
202202
mapD := map[string]string{"DownloadStatus": "Pending", "Msg": msg}
203203
mapB, _ := json.Marshal(mapD)
204-
h.broadcastSys <- mapB
204+
hub.broadcastSys <- mapB
205205
}
206206

207207
// if the default browser is Safari, prompt the user to install HTTPS certificates
@@ -399,13 +399,13 @@ func loop(stray *systray.Systray, configPath *paths.Path) {
399399
// launch the discoveries for the running system
400400
go serialPorts.Run()
401401
// launch the hub routine which is the singleton for the websocket server
402-
go h.run()
402+
go hub.run()
403403
// launch our dummy data routine
404404
//go d.run()
405405

406406
r := gin.New()
407407

408-
socketHandler := wsHandler(h).ServeHTTP
408+
socketHandler := wsHandler(hub).ServeHTTP
409409

410410
extraOrigins := []string{
411411
"https://create.arduino.cc",
@@ -444,13 +444,13 @@ func loop(stray *systray.Systray, configPath *paths.Path) {
444444
r.LoadHTMLFiles("templates/nofirefox.html")
445445

446446
r.GET("/", homeHandler)
447-
r.POST("/upload", uploadHandler(h, signaturePubKey))
447+
r.POST("/upload", uploadHandler(hub, signaturePubKey))
448448
r.GET("/socket.io/", socketHandler)
449449
r.POST("/socket.io/", socketHandler)
450450
r.Handle("WS", "/socket.io/", socketHandler)
451451
r.Handle("WSS", "/socket.io/", socketHandler)
452452
r.GET("/info", infoHandler)
453-
r.POST("/pause", PauseHandler(h, stray))
453+
r.POST("/pause", PauseHandler(hub, stray))
454454
r.POST("/update", UpdateHandler(stray))
455455

456456
// Mount goa handlers

main_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestValidSignatureKey(t *testing.T) {
5656

5757
func TestUploadHandlerAgainstEvilFileNames(t *testing.T) {
5858
r := gin.New()
59-
r.POST("/", uploadHandler(utilities.MustParseRsaPublicKey([]byte(globals.ArduinoSignaturePubKey))))
59+
r.POST("/", uploadHandler(NewHub(NewSerialHub(), NewSerialPortList()), utilities.MustParseRsaPublicKey([]byte(globals.ArduinoSignaturePubKey))))
6060
ts := httptest.NewServer(r)
6161

6262
uploadEvilFileName := Upload{
@@ -92,7 +92,8 @@ func TestUploadHandlerAgainstEvilFileNames(t *testing.T) {
9292

9393
func TestUploadHandlerAgainstBase64WithoutPaddingMustFail(t *testing.T) {
9494
r := gin.New()
95-
r.POST("/", uploadHandler(utilities.MustParseRsaPublicKey([]byte(globals.ArduinoSignaturePubKey))))
95+
96+
r.POST("/", uploadHandler(NewHub(NewSerialHub(), NewSerialPortList()), utilities.MustParseRsaPublicKey([]byte(globals.ArduinoSignaturePubKey))))
9697
ts := httptest.NewServer(r)
9798
defer ts.Close()
9899

0 commit comments

Comments
 (0)