pushInterface.go 323 B

1234567891011121314151617181920
  1. package bullet
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. )
  6. type pushInterface interface {
  7. getReader() (*bytes.Buffer, error)
  8. }
  9. func getReader(object interface{}) (*bytes.Buffer, error) {
  10. jsonBytes, err := json.Marshal(object)
  11. if err != nil {
  12. return nil, err
  13. }
  14. buffer := bytes.NewBuffer(jsonBytes)
  15. return buffer, nil
  16. }