statping/handlers/integrations.go

34 lines
662 B
Go
Raw Normal View History

2020-01-03 06:10:25 +00:00
package handlers
import (
"github.com/gorilla/mux"
"github.com/hunterlong/statping/integrations"
"net/http"
)
func apiAllIntegrationsHandler(w http.ResponseWriter, r *http.Request) {
integrations := integrations.Integrations
returnJson(integrations, w, r)
}
func apiIntegrationHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
intg := vars["name"]
r.ParseForm()
for k, v := range r.PostForm {
log.Info(k, v)
}
integration, err := integrations.Find(intg)
if err != nil {
sendErrorJson(err, w, r)
return
}
list, err := integration.List()
if err != nil {
sendErrorJson(err, w, r)
return
}
returnJson(list, w, r)
}