Browse Source

Update route registration

feature/add-http-image-upload
Roman Zipp 3 years ago
parent
commit
4f255bed04
  1. 7
      main.go
  2. 2
      main_test.go

7
main.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 {

2
main_test.go

@ -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()

Loading…
Cancel
Save