本文整理匯總了Golang中github.com/kylelemons/go-rpcgen/webrpc.ServeMux.Handle方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServeMux.Handle方法的具體用法?Golang ServeMux.Handle怎麽用?Golang ServeMux.Handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kylelemons/go-rpcgen/webrpc.ServeMux
的用法示例。
在下文中一共展示了ServeMux.Handle方法的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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}