request.go 541 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package rpc
  2. import (
  3. "encoding/json"
  4. "net"
  5. )
  6. type Request struct {
  7. body []byte
  8. conn net.Conn
  9. Method string
  10. Params map[string]interface{}
  11. }
  12. func (r *Request) Bind(v interface{}) (err error) {
  13. err = json.Unmarshal(r.body, v)
  14. return
  15. }
  16. func (r *Request) Encode() []byte {
  17. return nil
  18. }
  19. func (r *Request) ParamValue(name string) interface{} {
  20. return nil
  21. }
  22. func (r *Request) Reset(conn net.Conn) {
  23. r.conn = conn
  24. }
  25. func ReadRequest(b []byte) *Request {
  26. return &Request{}
  27. }
  28. func NewRequest() *Request {
  29. return &Request{}
  30. }