3pl/model/natsio/communication_response.go

27 lines
620 B
Go
Raw Normal View History

2022-08-15 04:51:07 +00:00
package natsiomodel
import "github.com/Selly-Modules/tpl/util/pjson"
// NatsResponse ...
type NatsResponse struct {
2022-08-15 10:28:35 +00:00
Response *HttpResponse `json:"response"`
Error bool `json:"error"`
Message string `json:"message"`
RequestID string `json:"requestId"`
2022-08-15 04:51:07 +00:00
}
2022-08-15 10:28:35 +00:00
// ParseResponseData ...
func (r *NatsResponse) ParseResponseData(result interface{}) error {
if r.Response == nil {
return nil
}
b := pjson.ToBytes(r.Response.Body)
2022-08-15 04:51:07 +00:00
return pjson.Unmarshal(b, result)
}
2022-08-15 10:28:35 +00:00
// HttpResponse ...
type HttpResponse struct {
Body string `json:"body"`
StatusCode int `json:"statusCode"`
}