package controllers import ( "encoding/json" "github.com/geplauder/lithium/pipelines" "net/http" ) type Metadata struct { Name string `json:"name"` Version string `json:"version"` CommitHash string `json:"commit_hash"` Pipelines []string `json:"pipelines"` } const Name string = "Lithium" const Version string = "0.1.0" func IndexHandler(pipelines []pipelines.IPipeline, w http.ResponseWriter, r *http.Request, gitCommit string) { var pipelineNames []string for _, x := range pipelines { pipelineNames = append(pipelineNames, x.GetSlug()) } w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(Metadata{Name, Version, gitCommit, pipelineNames}) if err != nil { w.WriteHeader(http.StatusInternalServerError) } }