|
|
@ -23,9 +23,10 @@ const Version string = "0.1.0" |
|
|
|
var GitCommit string |
|
|
|
|
|
|
|
type Metadata struct { |
|
|
|
Name string `json:"name"` |
|
|
|
Version string `json:"version"` |
|
|
|
CommitHash string `json:"commit_hash"` |
|
|
|
Name string `json:"name"` |
|
|
|
Version string `json:"version"` |
|
|
|
CommitHash string `json:"commit_hash"` |
|
|
|
Pipelines []string `json:"pipelines"` |
|
|
|
} |
|
|
|
|
|
|
|
func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStorageProvider, w http.ResponseWriter, r *http.Request) { |
|
|
@ -36,9 +37,14 @@ func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStor |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func IndexHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
func IndexHandler(pipelines []pipelines.IPipeline, w http.ResponseWriter, r *http.Request) { |
|
|
|
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}) |
|
|
|
err := json.NewEncoder(w).Encode(Metadata{Name, Version, GitCommit, pipelineNames}) |
|
|
|
if err != nil { |
|
|
|
w.WriteHeader(http.StatusInternalServerError) |
|
|
|
} |
|
|
@ -133,7 +139,9 @@ func UploadHandler(w http.ResponseWriter, r *http.Request, pipes []pipelines.IPi |
|
|
|
|
|
|
|
func RegisterRoutes(r *mux.Router, appSettings settings.Settings, pipelines []pipelines.IPipeline, storageProvider storage.IStorageProvider) { |
|
|
|
index := r.Methods(http.MethodGet).Subrouter() |
|
|
|
index.HandleFunc("/", IndexHandler) |
|
|
|
index.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
IndexHandler(pipelines, w, r) |
|
|
|
}) |
|
|
|
|
|
|
|
upload := r.Methods(http.MethodPost).Subrouter() |
|
|
|
upload.HandleFunc("/upload", func(w http.ResponseWriter, r *http.Request) { |
|
|
|