fix
This commit is contained in:
25
app/routers/metrics/task.go
Normal file
25
app/routers/metrics/task.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
tasks "monitoring/app/storage/clickhouse/tables"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func AddTaskMetric(r *http.Request) (interface{}, int) {
|
||||
d := json.NewDecoder(r.Body)
|
||||
body := tasks.TaskMetric{}
|
||||
err := d.Decode(&body)
|
||||
if err != nil {
|
||||
return nil, http.StatusBadRequest
|
||||
}
|
||||
|
||||
err = tasks.AddTaskMetric(body)
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
return nil, http.StatusInternalServerError
|
||||
}
|
||||
|
||||
return nil, http.StatusAccepted
|
||||
}
|
||||
Reference in New Issue
Block a user