Micro-service for file storage and processing written in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
781 B

  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/geplauder/lithium/pipelines"
  5. "net/http"
  6. )
  7. type Metadata struct {
  8. Name string `json:"name"`
  9. Version string `json:"version"`
  10. CommitHash string `json:"commit_hash"`
  11. Pipelines []string `json:"pipelines"`
  12. }
  13. const Name string = "Lithium"
  14. const Version string = "0.1.0"
  15. func IndexHandler(pipelines []pipelines.IPipeline, w http.ResponseWriter, r *http.Request, gitCommit string) {
  16. var pipelineNames []string
  17. for _, x := range pipelines {
  18. pipelineNames = append(pipelineNames, x.GetSlug())
  19. }
  20. w.Header().Set("Content-Type", "application/json")
  21. err := json.NewEncoder(w).Encode(Metadata{Name, Version, gitCommit, pipelineNames})
  22. if err != nil {
  23. w.WriteHeader(http.StatusInternalServerError)
  24. }
  25. }