Fix missing error check for jsonrpc.Server.RegisterService() (#2921)

This commit is contained in:
Aditya Manthramurthy 2016-10-13 17:34:10 -07:00 committed by Harshavardhana
parent eb372d53df
commit 31be826f51
2 changed files with 11 additions and 3 deletions

View File

@ -101,7 +101,9 @@ func configureServerHandler(srvCmdConfig serverCmdConfig) (http.Handler, error)
// set environmental variable MINIO_BROWSER=off to disable minio web browser.
// By default minio web browser is enabled.
if !strings.EqualFold(os.Getenv("MINIO_BROWSER"), "off") {
registerWebRouter(mux)
if err = registerWebRouter(mux); err != nil {
return nil, err
}
}
// Add API router.

View File

@ -58,7 +58,7 @@ func assetFS() *assetfs.AssetFS {
const specialAssets = "loader.css|logo.svg|firefox.png|safari.png|chrome.png|favicon.ico"
// registerWebRouter - registers web router for serving minio browser.
func registerWebRouter(mux *router.Router) {
func registerWebRouter(mux *router.Router) error {
// Initialize Web.
web := &webAPIHandlers{
ObjectAPI: newObjectLayerFn,
@ -74,7 +74,11 @@ func registerWebRouter(mux *router.Router) {
webRPC := jsonrpc.NewServer()
webRPC.RegisterCodec(codec, "application/json")
webRPC.RegisterCodec(codec, "application/json; charset=UTF-8")
webRPC.RegisterService(web, "Web")
// Register RPC handlers with server
if err := webRPC.RegisterService(web, "Web"); err != nil {
return err
}
// RPC handler at URI - /minio/webrpc
webBrowserRouter.Methods("POST").Path("/webrpc").Handler(webRPC)
@ -89,4 +93,6 @@ func registerWebRouter(mux *router.Router) {
// Serve index.html for rest of the requests.
webBrowserRouter.Path("/{index:.*}").Handler(indexHandler{http.StripPrefix(reservedBucket, http.FileServer(assetFS()))})
return nil
}