func TestServer(t *T) { Convey("server", t, func() { Convey("Create()", func() { Convey("It should create a new json server", func() { s, err := server.Create("json://127.0.0.1:6060", nil) So(err, ShouldEqual, nil) js, ok := s.(*Server) So(ok, ShouldEqual, true) So(js.Addr, ShouldEqual, "127.0.0.1:6060") }) }) }) }
// Server - Starts a servers. (does not add endpoint to the list) func (w *Worker) Server(address string, auth ...string) (err error) { // Get server by transport srv, err := server.Create(address, w, auth...) if err != nil { glog.Warningf("Server construction failed address=%s err=%v", address, err) return } // Add a server to the list w.Servers = append(w.Servers, srv) // Start server glog.Infof("Starting a server (address=%s)", address) err = srv.Start() if err != nil { glog.Infof("Server error %v (address=%s)", err, address) srv.Close() } return err }