init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,116 @@
|
||||
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
|
||||
}
|
||||
|
||||
func RegisterUIRoutes(
|
||||
mux *http.ServeMux,
|
||||
h UIHandlers,
|
||||
) {
|
||||
|
||||
mux.HandleFunc(
|
||||
"/healthz",
|
||||
h.Health,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/tree",
|
||||
h.Tree,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/new",
|
||||
h.NewPage,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/e",
|
||||
h.SemanticEditor,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/e/",
|
||||
h.SemanticEditor,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/raw",
|
||||
h.RawView,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/raw/",
|
||||
h.RawView,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/l",
|
||||
h.LinkManager,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/",
|
||||
func(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
if r.URL.Path == "/" {
|
||||
|
||||
h.Home(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
switch r.URL.Path {
|
||||
|
||||
case "/tree":
|
||||
|
||||
h.Tree(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
case "/new":
|
||||
|
||||
h.NewPage(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if r.URL.Path == "/e" ||
|
||||
r.URL.Path == "/raw" {
|
||||
|
||||
http.NotFound(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
h.SemanticPage(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user