forked from christiangalsterer/httpbeat
/
httpevent.go
38 lines (32 loc) · 837 Bytes
/
httpevent.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
package main
import (
"time"
"github.com/elastic/libbeat/common"
)
type HttpEvent struct {
ReadTime time.Time
DocumentType string
Fields *map[string]string
Request Request
Response Response
}
type Request struct {
Url string `json:"url,omitempty"`
Method string `json:"method,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Body string `json:"body,omitempty"`
}
type Response struct {
StatusCode int `json:"statusCode,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Body string `json:"body,omitempty"`
}
func (h *HttpEvent) ToMapStr() common.MapStr {
event := common.MapStr{
"@timestamp": common.Time(h.ReadTime),
"type": h.DocumentType,
"request": h.Request,
"response": h.Response,
}
return event
}