diff pkg/controllers/routes.go @ 3217:4c254651d80b

Added template types "map", "diagram", "report".
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 09 May 2019 12:08:02 +0200
parents c8ded555c2a8
children 60f25cbe77fb
line wrap: on
line diff
--- a/pkg/controllers/routes.go	Thu May 09 11:56:11 2019 +0200
+++ b/pkg/controllers/routes.go	Thu May 09 12:08:02 2019 +0200
@@ -101,25 +101,31 @@
 	}).Methods(http.MethodGet)
 
 	// Print templates
-	api.Handle("/templates/print", any(&JSONHandler{
+	api.Handle("/templates", any(&JSONHandler{
 		Handle: listPrintTemplates,
 	})).Methods(http.MethodGet)
 
-	api.Handle("/templates/print/{name}", any(&JSONHandler{
+	tTypes := "{type:" + strings.Join(templateTypes, "|") + "}"
+
+	api.Handle("/templates/"+tTypes, any(&JSONHandler{
+		Handle: listPrintTemplates,
+	})).Methods(http.MethodGet)
+
+	api.Handle("/templates/"+tTypes+"/{name}", any(&JSONHandler{
 		Handle: fetchPrintTemplate,
 	})).Methods(http.MethodGet)
 
-	api.Handle("/templates/print/{name}", waterwayAdmin(&JSONHandler{
+	api.Handle("/templates/"+tTypes+"/{name}", waterwayAdmin(&JSONHandler{
 		Input:  func(*http.Request) interface{} { return &json.RawMessage{} },
 		Handle: createPrintTemplate,
 		Limit:  maxPrintTemplateSize,
 	})).Methods(http.MethodPost)
 
-	api.Handle("/templates/print/{name}", waterwayAdmin(&JSONHandler{
+	api.Handle("/templates/"+tTypes+"/{name}", waterwayAdmin(&JSONHandler{
 		Handle: deletePrintTemplate,
 	})).Methods(http.MethodDelete)
 
-	api.Handle("/templates/print/{name}", waterwayAdmin(&JSONHandler{
+	api.Handle("/templates/"+tTypes+"/{name}", waterwayAdmin(&JSONHandler{
 		Input:  func(*http.Request) interface{} { return &json.RawMessage{} },
 		Handle: updatePrintTemplate,
 		Limit:  maxPrintTemplateSize,