-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsave.go
More file actions
28 lines (25 loc) · 656 Bytes
/
save.go
File metadata and controls
28 lines (25 loc) · 656 Bytes
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
package main
import (
"encoding/json"
"github.com/syndtr/goleveldb/leveldb"
"log"
"strings"
)
func SaveHttpData(db *leveldb.DB, save <-chan model) {
for md := range save {
if !strings.Contains(md.ResponseContextType, "text/plain") && !strings.Contains(md.ResponseContextType, "application/json") {
log.Printf("[PRISM] package is no text/plain,application/json")
continue
}
md.key()
byt, err := json.Marshal(md)
if err != nil {
log.Printf("[ERROR] marshal error (%s)", err.Error())
continue
}
if err := db.Put([]byte(md.Id), byt, nil); err != nil {
log.Printf("[ERROR] put error (%s)", err.Error())
continue
}
}
}