feat: fix db and recode judge
This commit is contained in:
@@ -6,28 +6,13 @@ import (
|
||||
|
||||
func Write(db *DB, resultCh <-chan *LogEntry) {
|
||||
for result := range resultCh {
|
||||
path := ""
|
||||
if result.Path != nil {
|
||||
path = *result.Path
|
||||
}
|
||||
|
||||
status := ""
|
||||
if result.Status != nil {
|
||||
status = *result.Status
|
||||
}
|
||||
|
||||
method := ""
|
||||
if result.Method != nil {
|
||||
method = *result.Method
|
||||
}
|
||||
|
||||
_, err := db.db.Exec(
|
||||
"INSERT INTO requests (service, ip, path, method, status, created_at) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
result.Service,
|
||||
result.IP,
|
||||
path,
|
||||
method,
|
||||
status,
|
||||
result.Path,
|
||||
result.Method,
|
||||
result.Status,
|
||||
time.Now().Format(time.RFC3339),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user