Skip to content

Commit

Permalink
Switch most callers from http.HandleFunc() to lib/html.HandleFunc().
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Oct 9, 2018
1 parent 111cf8b commit 3582705
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 44 deletions.
4 changes: 2 additions & 2 deletions cmd/mdbd/httpd.go
Expand Up @@ -27,8 +27,8 @@ func startHttpServer(portNum uint) (*httpServer, error) {
return nil, err
}
s := &httpServer{mdb: &mdb.Mdb{}}
http.HandleFunc("/", s.statusHandler)
http.HandleFunc("/showMdb", s.showMdbHandler)
html.HandleFunc("/", s.statusHandler)
html.HandleFunc("/showMdb", s.showMdbHandler)
go http.Serve(listener, nil)
return s, nil
}
Expand Down
18 changes: 9 additions & 9 deletions dom/herd/httpd.go
Expand Up @@ -13,20 +13,20 @@ func (herd *Herd) startServer(portNum uint, daemon bool) error {
if err != nil {
return err
}
http.HandleFunc("/", herd.statusHandler)
http.HandleFunc("/listReachableSubs", herd.listReachableSubsHandler)
http.HandleFunc("/listSubs", herd.listSubsHandler)
http.HandleFunc("/showAliveSubs",
html.HandleFunc("/", herd.statusHandler)
html.HandleFunc("/listReachableSubs", herd.listReachableSubsHandler)
html.HandleFunc("/listSubs", herd.listSubsHandler)
html.HandleFunc("/showAliveSubs",
html.BenchmarkedHandler(herd.showAliveSubsHandler))
http.HandleFunc("/showAllSubs",
html.HandleFunc("/showAllSubs",
html.BenchmarkedHandler(herd.showAllSubsHandler))
http.HandleFunc("/showCompliantSubs",
html.HandleFunc("/showCompliantSubs",
html.BenchmarkedHandler(herd.showCompliantSubsHandler))
http.HandleFunc("/showDeviantSubs",
html.HandleFunc("/showDeviantSubs",
html.BenchmarkedHandler(herd.showDeviantSubsHandler))
http.HandleFunc("/showReachableSubs",
html.HandleFunc("/showReachableSubs",
html.BenchmarkedHandler(herd.showReachableSubsHandler))
http.HandleFunc("/showSub", html.BenchmarkedHandler(herd.showSubHandler))
html.HandleFunc("/showSub", html.BenchmarkedHandler(herd.showSubHandler))
if daemon {
go http.Serve(listener, nil)
} else {
Expand Down
3 changes: 2 additions & 1 deletion fleetmanager/httpd/api.go
Expand Up @@ -8,6 +8,7 @@ import (
"sync"

"github.com/Symantec/Dominator/fleetmanager/topology"
"github.com/Symantec/Dominator/lib/html"
"github.com/Symantec/Dominator/lib/log"
)

Expand All @@ -28,7 +29,7 @@ func StartServer(portNum uint, logger log.DebugLogger) (*Server, error) {
return nil, err
}
server := &Server{logger: logger}
http.HandleFunc("/", server.statusHandler)
html.HandleFunc("/", server.statusHandler)
go http.Serve(listener, nil)
return server, nil
}
Expand Down
11 changes: 5 additions & 6 deletions fleetmanager/hypervisors/start.go
@@ -1,8 +1,7 @@
package hypervisors

import (
"net/http"

"github.com/Symantec/Dominator/lib/html"
"github.com/Symantec/Dominator/lib/log"
)

Expand All @@ -19,10 +18,10 @@ func newManager(storer Storer, logger log.DebugLogger) (*Manager, error) {
vms: make(map[string]*vmInfoType),
}
manager.initInvertTable()
http.HandleFunc("/listHypervisors", manager.listHypervisorsHandler)
http.HandleFunc("/listLocations", manager.listLocationsHandler)
http.HandleFunc("/listVMs", manager.listVMsHandler)
http.HandleFunc("/showHypervisor", manager.showHypervisorHandler)
html.HandleFunc("/listHypervisors", manager.listHypervisorsHandler)
html.HandleFunc("/listLocations", manager.listLocationsHandler)
html.HandleFunc("/listVMs", manager.listVMsHandler)
html.HandleFunc("/showHypervisor", manager.showHypervisorHandler)
go manager.notifierLoop()
return manager, nil
}
13 changes: 7 additions & 6 deletions hypervisor/httpd/api.go
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/Symantec/Dominator/hypervisor/manager"
"github.com/Symantec/Dominator/lib/html"
)

type HtmlWriter interface {
Expand All @@ -25,13 +26,13 @@ func StartServer(portNum uint, managerObj *manager.Manager, daemon bool) error {
return err
}
myState := state{managerObj}
http.HandleFunc("/", myState.statusHandler)
http.HandleFunc("/listAvailableAddresses",
html.HandleFunc("/", myState.statusHandler)
html.HandleFunc("/listAvailableAddresses",
myState.listAvailableAddressesHandler)
http.HandleFunc("/listSubnets", myState.listSubnetsHandler)
http.HandleFunc("/listVMs", myState.listVMsHandler)
http.HandleFunc("/showVmBootLog", myState.showBootLogHandler)
http.HandleFunc("/showVM", myState.showVMHandler)
html.HandleFunc("/listSubnets", myState.listSubnetsHandler)
html.HandleFunc("/listVMs", myState.listVMsHandler)
html.HandleFunc("/showVmBootLog", myState.showBootLogHandler)
html.HandleFunc("/showVM", myState.showVMHandler)
if daemon {
go http.Serve(listener, nil)
} else {
Expand Down
11 changes: 6 additions & 5 deletions imagebuilder/httpd/api.go
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/Symantec/Dominator/imagebuilder/builder"
"github.com/Symantec/Dominator/lib/html"
)

type HtmlWriter interface {
Expand All @@ -26,11 +27,11 @@ func StartServer(portNum uint, builderObj *builder.Builder,
return err
}
myState := state{builderObj}
http.HandleFunc("/", myState.statusHandler)
http.HandleFunc("/showCurrentBuildLog", myState.showCurrentBuildLogHandler)
http.HandleFunc("/showImageStream", myState.showImageStreamHandler)
http.HandleFunc("/showImageStreams", myState.showImageStreamsHandler)
http.HandleFunc("/showLastBuildLog", myState.showLastBuildLogHandler)
html.HandleFunc("/", myState.statusHandler)
html.HandleFunc("/showCurrentBuildLog", myState.showCurrentBuildLogHandler)
html.HandleFunc("/showImageStream", myState.showImageStreamHandler)
html.HandleFunc("/showImageStreams", myState.showImageStreamsHandler)
html.HandleFunc("/showLastBuildLog", myState.showLastBuildLogHandler)
if daemon {
go http.Serve(listener, nil)
} else {
Expand Down
23 changes: 12 additions & 11 deletions imageserver/httpd/api.go
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/Symantec/Dominator/imageserver/scanner"
"github.com/Symantec/Dominator/lib/html"
"github.com/Symantec/Dominator/lib/objectserver/filesystem"
)

Expand All @@ -28,17 +29,17 @@ func StartServer(portNum uint, imdb *scanner.ImageDataBase,
return err
}
myState := state{imageDataBase: imdb, objectServer: objSrv}
http.HandleFunc("/", statusHandler)
http.HandleFunc("/listBuildLog", myState.listBuildLogHandler)
http.HandleFunc("/listComputedInodes", myState.listComputedInodesHandler)
http.HandleFunc("/listDirectories", myState.listDirectoriesHandler)
http.HandleFunc("/listFilter", myState.listFilterHandler)
http.HandleFunc("/listImage", myState.listImageHandler)
http.HandleFunc("/listImages", myState.listImagesHandler)
http.HandleFunc("/listPackages", myState.listPackagesHandler)
http.HandleFunc("/listReleaseNotes", myState.listReleaseNotesHandler)
http.HandleFunc("/listTriggers", myState.listTriggersHandler)
http.HandleFunc("/showImage", myState.showImageHandler)
html.HandleFunc("/", statusHandler)
html.HandleFunc("/listBuildLog", myState.listBuildLogHandler)
html.HandleFunc("/listComputedInodes", myState.listComputedInodesHandler)
html.HandleFunc("/listDirectories", myState.listDirectoriesHandler)
html.HandleFunc("/listFilter", myState.listFilterHandler)
html.HandleFunc("/listImage", myState.listImageHandler)
html.HandleFunc("/listImages", myState.listImagesHandler)
html.HandleFunc("/listPackages", myState.listPackagesHandler)
html.HandleFunc("/listReleaseNotes", myState.listReleaseNotesHandler)
html.HandleFunc("/listTriggers", myState.listTriggersHandler)
html.HandleFunc("/showImage", myState.showImageHandler)
if daemon {
go http.Serve(listener, nil)
} else {
Expand Down
5 changes: 3 additions & 2 deletions imageunpacker/httpd/api.go
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/Symantec/Dominator/imageunpacker/unpacker"
"github.com/Symantec/Dominator/lib/html"
)

type HtmlWriter interface {
Expand All @@ -26,8 +27,8 @@ func StartServer(portNum uint, unpackerObj *unpacker.Unpacker,
return err
}
myState := state{unpackerObj}
http.HandleFunc("/", myState.statusHandler)
http.HandleFunc("/showFileSystem", myState.showFileSystemHandler)
html.HandleFunc("/", myState.statusHandler)
html.HandleFunc("/showFileSystem", myState.showFileSystemHandler)
if daemon {
go http.Serve(listener, nil)
} else {
Expand Down
5 changes: 3 additions & 2 deletions lib/filegen/httpd/api.go
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/Symantec/Dominator/lib/filegen"
"github.com/Symantec/Dominator/lib/html"
)

type HtmlWriter interface {
Expand All @@ -25,8 +26,8 @@ func StartServer(portNum uint, manager *filegen.Manager, daemon bool) error {
return err
}
myState := &state{manager}
http.HandleFunc("/", myState.statusHandler)
http.HandleFunc("/listGenerators", myState.listGeneratorsHandler)
html.HandleFunc("/", myState.statusHandler)
html.HandleFunc("/listGenerators", myState.listGeneratorsHandler)
if daemon {
go http.Serve(listener, nil)
} else {
Expand Down

0 comments on commit 3582705

Please sign in to comment.