package routes import "net/http" type UIHandlers struct { Home http.HandlerFunc NewPage http.HandlerFunc SemanticEditor http.HandlerFunc SemanticPage http.HandlerFunc RawView http.HandlerFunc LinkManager http.HandlerFunc Health http.HandlerFunc Tree http.HandlerFunc Browser http.HandlerFunc Preview http.HandlerFunc PlainView http.HandlerFunc MarkdownView http.HandlerFunc CompileMarkdown http.HandlerFunc CompileDiagram http.HandlerFunc Config http.HandlerFunc } func handleIfNotNil( mux *http.ServeMux, pattern string, h http.HandlerFunc, ) { if h != nil { mux.HandleFunc(pattern, h) } } func RegisterUIRoutes( mux *http.ServeMux, h UIHandlers, ) { handleIfNotNil(mux, "/", h.Home) handleIfNotNil(mux, "/:/new", h.NewPage) handleIfNotNil(mux, "/new", func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/:/new", http.StatusFound) }) handleIfNotNil(mux, "/e/", h.SemanticEditor) handleIfNotNil(mux, "/r/", h.RawView) handleIfNotNil(mux, "/l/", h.LinkManager) handleIfNotNil(mux, "/health", h.Health) handleIfNotNil(mux, "/v/tree", h.Tree) handleIfNotNil(mux, "/v/browser", h.Browser) handleIfNotNil(mux, "/v/browser/", h.Browser) handleIfNotNil(mux, "/v/preview", h.Preview) handleIfNotNil(mux, "/v/preview/", h.Preview) handleIfNotNil(mux, "/v/plain", h.PlainView) handleIfNotNil(mux, "/v/plain/", h.PlainView) handleIfNotNil(mux, "/v/markdown", h.MarkdownView) handleIfNotNil(mux, "/v/markdown/", h.MarkdownView) handleIfNotNil(mux, "/:/compile/markdown", h.CompileMarkdown) handleIfNotNil(mux, "/:/compile/markdown/", h.CompileMarkdown) handleIfNotNil(mux, "/:/compile/diagram/", h.CompileDiagram) handleIfNotNil(mux, "/-/sys/config", h.Config) }