package rpc

type Context struct {
	req *Request
	res *Response
}

func (c *Context) Reset(req *Request, res *Response) {
	c.req = req
	c.res = res
}

func (c *Context) Request() *Request {
	return c.req
}

func (c *Context) Response() *Response {
	return c.res
}

func (c *Context) Bind(i interface{}) (err error) {
	return c.Request().Decode(i)
}

func (c *Context) Success(i interface{}) (err error) {
	return c.Response().SetBody(i)
}

func (c *Context) Error(code int, message string) (err error) {
	c.Response().code = uint16(code)
	c.Response().message = message
	return
}
