|
@ -25,6 +25,7 @@ type Metadata struct { |
|
|
Name string `json:"name"` |
|
|
Name string `json:"name"` |
|
|
Version string `json:"version"` |
|
|
Version string `json:"version"` |
|
|
CommitHash string `json:"commit_hash"` |
|
|
CommitHash string `json:"commit_hash"` |
|
|
|
|
|
Pipelines []string `json:"pipelines"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStorageProvider, w http.ResponseWriter, r *http.Request) { |
|
|
func PipelineHandler(pipeline pipelines.IPipeline, storageProvider storage.IStorageProvider, w http.ResponseWriter, r *http.Request) { |
|
@ -35,9 +36,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") |
|
|
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 { |
|
|
if err != nil { |
|
|
w.WriteHeader(http.StatusInternalServerError) |
|
|
w.WriteHeader(http.StatusInternalServerError) |
|
|
} |
|
|
} |
|
@ -132,7 +138,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) { |
|
|
func RegisterRoutes(r *mux.Router, appSettings settings.Settings, pipelines []pipelines.IPipeline, storageProvider storage.IStorageProvider) { |
|
|
index := r.Methods(http.MethodGet).Subrouter() |
|
|
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 := r.Methods(http.MethodPost).Subrouter() |
|
|
upload.HandleFunc("/upload", func(w http.ResponseWriter, r *http.Request) { |
|
|
upload.HandleFunc("/upload", func(w http.ResponseWriter, r *http.Request) { |
|
|