Browse Source
Update route registration
feature/update-route-registration
Roman Zipp
3 years ago
committed by
Fabian Vowie
No known key found for this signature in database
GPG Key ID: C27317C33B27C410
2 changed files with
5 additions and
4 deletions
-
main.go
-
main_test.go
|
|
@ -36,7 +36,9 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func RegisterPipelineRoutes(r *mux.Router, pipelines []pipelines.IPipeline, storageProvider storage.IStorageProvider) { |
|
|
|
func RegisterRoutes(r *mux.Router, pipelines []pipelines.IPipeline, storageProvider storage.IStorageProvider) { |
|
|
|
r.HandleFunc("/", IndexHandler) |
|
|
|
|
|
|
|
for _, pipeline := range pipelines { |
|
|
|
r.HandleFunc("/"+pipeline.GetSlug(), func(w http.ResponseWriter, r *http.Request) { |
|
|
|
PipelineHandler(pipeline, storageProvider, w, r) |
|
|
@ -64,9 +66,8 @@ func main() { |
|
|
|
|
|
|
|
r := mux.NewRouter() |
|
|
|
r.Use(authMiddleware.Middleware) |
|
|
|
r.HandleFunc("/", IndexHandler) |
|
|
|
|
|
|
|
RegisterPipelineRoutes(r, pipes, storageProvider) |
|
|
|
RegisterRoutes(r, pipes, storageProvider) |
|
|
|
|
|
|
|
err = http.ListenAndServe(appSettings.Endpoint, r) |
|
|
|
if err != nil { |
|
|
|
|
|
@ -34,7 +34,7 @@ func TestEndpointRoute(t *testing.T) { |
|
|
|
router := mux.NewRouter() |
|
|
|
fs := storage.GetMemoryStorageProvider() |
|
|
|
|
|
|
|
RegisterPipelineRoutes(router, []pipelines.IPipeline{data}, fs) |
|
|
|
RegisterRoutes(router, []pipelines.IPipeline{data}, fs) |
|
|
|
|
|
|
|
request, _ := http.NewRequest("GET", "/"+data.Slug, nil) |
|
|
|
responseRecorder := httptest.NewRecorder() |
|
|
|