info.go 546 B

12345678910111213141516171819202122232425262728
  1. package api
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "github.com/ncarlier/webhookd/pkg/version"
  6. )
  7. // Info API informations model structure.
  8. type Info struct {
  9. Name string `json:"name"`
  10. Version string `json:"version"`
  11. }
  12. func infoHandler(w http.ResponseWriter, r *http.Request) {
  13. info := Info{
  14. Name: "webhookd",
  15. Version: version.Version,
  16. }
  17. data, err := json.Marshal(info)
  18. if err != nil {
  19. http.Error(w, err.Error(), http.StatusInternalServerError)
  20. return
  21. }
  22. w.Header().Set("Content-Type", "application/json")
  23. w.Write(data)
  24. }