@@ -263,7 +263,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error {
263263 n .stopInProc ()
264264 return err
265265 }
266- if err := n .startHTTP (n .httpEndpoint , apis , n .config .HTTPModules , n .config .HTTPCors ); err != nil {
266+ if err := n .startHTTP (n .httpEndpoint , apis , n .config .HTTPModules , n .config .HTTPCors , n . config . HTTPVirtualHosts ); err != nil {
267267 n .stopIPC ()
268268 n .stopInProc ()
269269 return err
@@ -287,7 +287,7 @@ func (n *Node) startInProc(apis []rpc.API) error {
287287 if err := handler .RegisterName (api .Namespace , api .Service ); err != nil {
288288 return err
289289 }
290- n .log .Debug (fmt . Sprintf ( "InProc registered %T under '%s'" , api .Service , api .Namespace ) )
290+ n .log .Debug ("InProc registered" , "service" , api .Service , "namespace" , api .Namespace )
291291 }
292292 n .inprocHandler = handler
293293 return nil
@@ -313,7 +313,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
313313 if err := handler .RegisterName (api .Namespace , api .Service ); err != nil {
314314 return err
315315 }
316- n .log .Debug (fmt . Sprintf ( "IPC registered %T under '%s'" , api .Service , api .Namespace ) )
316+ n .log .Debug ("IPC registered" , "service" , api .Service , "namespace" , api .Namespace )
317317 }
318318 // All APIs registered, start the IPC listener
319319 var (
@@ -324,7 +324,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
324324 return err
325325 }
326326 go func () {
327- n .log .Info (fmt . Sprintf ( "IPC endpoint opened: %s" , n .ipcEndpoint ))
327+ n .log .Info ("IPC endpoint opened" , "url" , fmt . Sprintf ( " %s" , n .ipcEndpoint ))
328328
329329 for {
330330 conn , err := listener .Accept ()
@@ -337,7 +337,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
337337 return
338338 }
339339 // Not closed, just some error; report and continue
340- n .log .Error (fmt . Sprintf ( "IPC accept failed: %v" , err ) )
340+ n .log .Error ("IPC accept failed" , "err" , err )
341341 continue
342342 }
343343 go handler .ServeCodec (rpc .NewJSONCodec (conn ), rpc .OptionMethodInvocation | rpc .OptionSubscriptions )
@@ -356,7 +356,7 @@ func (n *Node) stopIPC() {
356356 n .ipcListener .Close ()
357357 n .ipcListener = nil
358358
359- n .log .Info (fmt . Sprintf ( "IPC endpoint closed: %s" , n .ipcEndpoint ) )
359+ n .log .Info ("IPC endpoint closed" , "endpoint" , n .ipcEndpoint )
360360 }
361361 if n .ipcHandler != nil {
362362 n .ipcHandler .Stop ()
@@ -365,7 +365,7 @@ func (n *Node) stopIPC() {
365365}
366366
367367// startHTTP initializes and starts the HTTP RPC endpoint.
368- func (n * Node ) startHTTP (endpoint string , apis []rpc.API , modules []string , cors []string ) error {
368+ func (n * Node ) startHTTP (endpoint string , apis []rpc.API , modules []string , cors []string , vhosts [] string ) error {
369369 // Short circuit if the HTTP endpoint isn't being exposed
370370 if endpoint == "" {
371371 return nil
@@ -382,7 +382,7 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
382382 if err := handler .RegisterName (api .Namespace , api .Service ); err != nil {
383383 return err
384384 }
385- n .log .Debug (fmt . Sprintf ( "HTTP registered %T under '%s'" , api .Service , api .Namespace ) )
385+ n .log .Debug ("HTTP registered" , "service" , api .Service , "namespace" , api .Namespace )
386386 }
387387 }
388388 // All APIs registered, start the HTTP listener
@@ -393,9 +393,8 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
393393 if listener , err = net .Listen ("tcp" , endpoint ); err != nil {
394394 return err
395395 }
396- go rpc .NewHTTPServer (cors , handler ).Serve (listener )
397- n .log .Info (fmt .Sprintf ("HTTP endpoint opened: http://%s" , endpoint ))
398-
396+ go rpc .NewHTTPServer (cors , vhosts , handler ).Serve (listener )
397+ n .log .Info ("HTTP endpoint opened" , "url" , fmt .Sprintf ("http://%s" , endpoint ), "cors" , strings .Join (cors , "," ), "hvosts" , strings .Join (vhosts , "," ))
399398 // All listeners booted successfully
400399 n .httpEndpoint = endpoint
401400 n .httpListener = listener
@@ -410,7 +409,7 @@ func (n *Node) stopHTTP() {
410409 n .httpListener .Close ()
411410 n .httpListener = nil
412411
413- n .log .Info (fmt . Sprintf ( "HTTP endpoint closed: http://%s" , n .httpEndpoint ))
412+ n .log .Info ("HTTP endpoint closed" , "url" , fmt . Sprintf ( " http://%s" , n .httpEndpoint ))
414413 }
415414 if n .httpHandler != nil {
416415 n .httpHandler .Stop ()
@@ -436,7 +435,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
436435 if err := handler .RegisterName (api .Namespace , api .Service ); err != nil {
437436 return err
438437 }
439- n .log .Debug (fmt . Sprintf ( "WebSocket registered %T under '%s'" , api .Service , api .Namespace ) )
438+ n .log .Debug ("WebSocket registered" , "service" , api .Service , "namespace" , api .Namespace )
440439 }
441440 }
442441 // All APIs registered, start the HTTP listener
@@ -448,7 +447,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
448447 return err
449448 }
450449 go rpc .NewWSServer (wsOrigins , handler ).Serve (listener )
451- n .log .Info (fmt . Sprintf ( "WebSocket endpoint opened: ws://%s" , listener .Addr ()))
450+ n .log .Info ("WebSocket endpoint opened" , "url" , fmt . Sprintf ( " ws://%s" , listener .Addr ()))
452451
453452 // All listeners booted successfully
454453 n .wsEndpoint = endpoint
@@ -464,7 +463,7 @@ func (n *Node) stopWS() {
464463 n .wsListener .Close ()
465464 n .wsListener = nil
466465
467- n .log .Info (fmt . Sprintf ( "WebSocket endpoint closed: ws://%s" , n .wsEndpoint ))
466+ n .log .Info ("WebSocket endpoint closed" , "url" , fmt . Sprintf ( " ws://%s" , n .wsEndpoint ))
468467 }
469468 if n .wsHandler != nil {
470469 n .wsHandler .Stop ()
0 commit comments