forked from FabianVowie/Lithium
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
30 lines
781 B
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)
|
|
}
|
|
}
|