-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathevent.go
40 lines (35 loc) · 1.28 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package rest
import (
"fmt"
"github.com/viant/endly/model/msg"
"github.com/viant/toolbox"
)
// Messages returns messages
func (r *Request) Messages() []*msg.Message {
var response = make([]*msg.Message, 0)
response = append(response, msg.NewMessage(msg.NewStyled(fmt.Sprintf("%v %v", r.Method, r.URL), msg.MessageStyleGeneric), msg.NewStyled("rest.Request", msg.MessageStyleGeneric)))
if r.Request != nil {
requestJSON, _ := toolbox.AsJSONText(r.Request)
response = append(response, msg.NewMessage(msg.NewStyled("Request", msg.MessageStyleGeneric), msg.NewStyled("rest.Request", msg.MessageStyleGeneric),
msg.NewStyled(requestJSON, msg.MessageStyleInput),
))
}
return response
}
// Messages returns messages
func (r *Response) Messages() []*msg.Message {
var response = make([]*msg.Message, 0)
responseJSON, _ := toolbox.AsJSONText(r)
response = append(response, msg.NewMessage(msg.NewStyled("Response", msg.MessageStyleGeneric), msg.NewStyled("rest.Response", msg.MessageStyleGeneric),
msg.NewStyled(responseJSON, msg.MessageStyleOutput),
))
return response
}
// IsInput returns this request (CLI reporter interface)
func (r *Request) IsInput() bool {
return true
}
// IsOutput returns this response (CLI reporter interface)
func (r *Response) IsOutput() bool {
return true
}