mirror of
https://github.com/Zhouchaowen/prism.git
synced 2025-09-26 20:11:19 +08:00
29 lines
656 B
Go
29 lines
656 B
Go
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
|
|
}
|
|
}
|
|
}
|