api: push silence validation into provider

This commit is contained in:
Fabian Reinartz 2016-06-09 15:38:40 +02:00
parent 6ad866dd27
commit 00b1a396af

13
api.go
View File

@ -293,17 +293,6 @@ func (api *API) addSilence(w http.ResponseWriter, r *http.Request) {
}
sil := types.NewSilence(&msil)
// if sil.CreatedAt.IsZero() {
// sil.CreatedAt = time.Now()
// }
if err := sil.Validate(); err != nil {
respondError(w, apiError{
typ: errorBadData,
err: err,
}, nil)
return
}
if err := sil.Init(); err != nil {
respondError(w, apiError{
typ: errorBadData,
@ -430,7 +419,7 @@ func respondError(w http.ResponseWriter, apiErr apiError, data interface{}) {
if err != nil {
return
}
log.Errorf("api error: %v", apiErr)
log.Errorf("api error: %s", apiErr)
w.Write(b)
}