本文整理汇总了Golang中rpc.Request类的典型用法代码示例。如果您正苦于以下问题:Golang Request类的具体用法?Golang Request怎么用?Golang Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReadRequestHeader
func (c *serverCodec) ReadRequestHeader(r *rpc.Request) (err os.Error) {
c.req.header.Reset()
lbuf := make([]byte, lenSize)
_, err = io.ReadFull(c.c, lbuf)
if err != nil {
return
}
pbuf := make([]byte, decodeLen(lbuf))
_, err = io.ReadFull(c.c, pbuf)
if err != nil {
return
}
c.req.header.SetBuf(pbuf)
h := new(Header)
err = c.req.header.Unmarshal(h)
if err != nil {
return
}
r.Seq = *h.Seq
r.ServiceMethod = *h.ServiceMethod
return
}
示例2: ReadRequestHeader
func (qx *queryCodec) ReadRequestHeader(req *rpc.Request) os.Error {
if qx.seq == 0 {
return os.EOF
}
req.Seq = qx.seq
req.ServiceMethod = pathToServiceMethod(qx.Req.URL.Path)
return nil
}
示例3: ReadRequestHeader
func (c *serverCodec) ReadRequestHeader(r *rpc.Request) os.Error {
c.req.reset()
if err := c.dec.Decode(&c.req); err != nil {
return err
}
r.ServiceMethod = c.req.Method
// JSON request id can be any JSON value;
// RPC package expects uint64. Translate to
// internal uint64 and save JSON on the side.
c.mutex.Lock()
c.seq++
c.pending[c.seq] = c.req.Id
c.req.Id = nil
r.Seq = c.seq
c.mutex.Unlock()
return nil
}