26 lines
500 B
Go
26 lines
500 B
Go
package routers
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
increments "monitoring/app/storage/clickhouse/tables"
|
|
"net/http"
|
|
)
|
|
|
|
func AddIncrementMetric(r *http.Request) (interface{}, int) {
|
|
d := json.NewDecoder(r.Body)
|
|
body := increments.IncrementMetric{}
|
|
err := d.Decode(&body)
|
|
if err != nil {
|
|
return nil, http.StatusBadRequest
|
|
}
|
|
|
|
err = increments.AddIncrementMetric(body)
|
|
if err != nil {
|
|
log.Print(err.Error())
|
|
return nil, http.StatusInternalServerError
|
|
}
|
|
|
|
return nil, http.StatusAccepted
|
|
}
|