This commit is contained in:
Anya Tokugawa committed 2026-05-19 21:30:42 +09:00
commit fa6a4c650f
93 files changed
+6555

No files matched your search

+78
View File
@@ -0,0 +1,78 @@
package routes
import "net/http"
type APIHandlers struct {
CreateObject http.HandlerFunc
ListObjects http.HandlerFunc
SaveRevision http.HandlerFunc
ListRevisions http.HandlerFunc
RestoreRevision http.HandlerFunc
RenderMarkdown http.HandlerFunc
AddTag http.HandlerFunc
BindPath http.HandlerFunc
RenamePath http.HandlerFunc
RenamePreview http.HandlerFunc
RemovePath http.HandlerFunc
}
func RegisterAPIRoutes(
mux *http.ServeMux,
h APIHandlers,
) {
mux.HandleFunc(
"/_/api/v1/object/create",
h.CreateObject,
)
mux.HandleFunc(
"/_/api/v1/object/list",
h.ListObjects,
)
mux.HandleFunc(
"/_/api/v1/revisions/save",
h.SaveRevision,
)
mux.HandleFunc(
"/_/api/v1/revisions/list",
h.ListRevisions,
)
mux.HandleFunc(
"/_/api/v1/revisions/restore",
h.RestoreRevision,
)
mux.HandleFunc(
"/_/api/v1/render/markdown",
h.RenderMarkdown,
)
mux.HandleFunc(
"/_/api/v1/tag/add",
h.AddTag,
)
mux.HandleFunc(
"/_/api/v1/path/bind",
h.BindPath,
)
mux.HandleFunc(
"/_/api/v1/path/rename",
h.RenamePath,
)
mux.HandleFunc(
"/_/api/v1/path/rename-preview",
h.RenamePreview,
)
mux.HandleFunc(
"/_/api/v1/path/remove",
h.RemovePath,
)
}
+116
View File
@@ -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,
)
},
)
}