當前位置: 首頁>>代碼示例>>Golang>>正文


Golang webrpc.ServeMux類代碼示例

本文整理匯總了Golang中github.com/kylelemons/go-rpcgen/webrpc.ServeMux的典型用法代碼示例。如果您正苦於以下問題:Golang ServeMux類的具體用法?Golang ServeMux怎麽用?Golang ServeMux使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ServeMux類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RegisterLearnerWeb

// Register a LearnerWeb implementation with the given webrpc ServeMux.
// If mux is nil, the default webrpc.ServeMux is used.
func RegisterLearnerWeb(this LearnerWeb, mux webrpc.ServeMux) error {
	if mux == nil {
		mux = webrpc.DefaultServeMux
	}
	if err := mux.Handle("/Learner/Lookup", func(c *webrpc.Call) error {
		in, out := new(File), new(File)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Lookup(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	if err := mux.Handle("/Learner/Learn", func(c *webrpc.Call) error {
		in, out := new(Proposal), new(Ack)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Learn(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	return nil
}
開發者ID:kylelemons,項目名稱:go-paxos,代碼行數:32,代碼來源:rpc.pb.go

示例2: RegisterAcceptorWeb

// Register a AcceptorWeb implementation with the given webrpc ServeMux.
// If mux is nil, the default webrpc.ServeMux is used.
func RegisterAcceptorWeb(this AcceptorWeb, mux webrpc.ServeMux) error {
	if mux == nil {
		mux = webrpc.DefaultServeMux
	}
	if err := mux.Handle("/Acceptor/Propose", func(c *webrpc.Call) error {
		in, out := new(Proposal), new(Promise)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Propose(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	if err := mux.Handle("/Acceptor/Accept", func(c *webrpc.Call) error {
		in, out := new(Proposal), new(Ack)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Accept(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	return nil
}
開發者ID:kylelemons,項目名稱:go-paxos,代碼行數:32,代碼來源:rpc.pb.go

示例3: RegisterAddServiceWeb

// Register a AddServiceWeb implementation with the given webrpc ServeMux.
// If mux is nil, the default webrpc.ServeMux is used.
func RegisterAddServiceWeb(this AddServiceWeb, mux webrpc.ServeMux) error {
	if mux == nil {
		mux = webrpc.DefaultServeMux
	}
	if err := mux.Handle("/AddService/Add", func(c *webrpc.Call) error {
		in, out := new(AddMessage), new(SumMessage)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Add(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	return nil
}
開發者ID:kylelemons,項目名稱:go-rpcgen,代碼行數:20,代碼來源:addservice.pb.go

示例4: RegisterWhoamiServiceWeb

// Register a WhoamiServiceWeb implementation with the given webrpc ServeMux.
// If mux is nil, the default webrpc.ServeMux is used.
func RegisterWhoamiServiceWeb(this WhoamiServiceWeb, mux webrpc.ServeMux) error {
	if mux == nil {
		mux = webrpc.DefaultServeMux
	}
	if err := mux.Handle("/WhoamiService/Whoami", func(c *webrpc.Call) error {
		in, out := new(Empty), new(YouAre)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Whoami(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	return nil
}
開發者ID:kylelemons,項目名稱:go-rpcgen,代碼行數:20,代碼來源:whoami.ae.go

示例5: RegisterConcatServiceWeb

// Register a ConcatServiceWeb implementation with the given webrpc ServeMux.
// If mux is nil, the default webrpc.ServeMux is used.
func RegisterConcatServiceWeb(this ConcatServiceWeb, mux webrpc.ServeMux) error {
	if mux == nil {
		mux = webrpc.DefaultServeMux
	}
	if err := mux.Handle("/ConcatService/Concat", func(c *webrpc.Call) error {
		in, out := new(Args), new(Return)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Concat(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	return nil
}
開發者ID:kylelemons,項目名稱:go-rpcgen,代碼行數:20,代碼來源:service.pb.go

示例6: RegisterOffloadServiceWeb

// Register a OffloadServiceWeb implementation with the given webrpc ServeMux.
// If mux is nil, the default webrpc.ServeMux is used.
func RegisterOffloadServiceWeb(this OffloadServiceWeb, mux webrpc.ServeMux) error {
	if mux == nil {
		mux = webrpc.DefaultServeMux
	}
	if err := mux.Handle("/OffloadService/Compute", func(c *webrpc.Call) error {
		in, out := new(DataSet), new(ResultSet)
		if err := c.ReadRequest(in); err != nil {
			return err
		}
		if err := this.Compute(c.Request, in, out); err != nil {
			return err
		}
		return c.WriteResponse(out)
	}); err != nil {
		return err
	}
	return nil
}
開發者ID:kylelemons,項目名稱:go-rpcgen,代碼行數:20,代碼來源:offload.pb.go


注:本文中的github.com/kylelemons/go-rpcgen/webrpc.ServeMux類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。