-
Notifications
You must be signed in to change notification settings - Fork 4
/
routes.go
59 lines (44 loc) · 1.85 KB
/
routes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Package routes - Content managed by Project Forge, see [projectforge.md] for details.
package routes
import (
"net/http"
"github.com/gorilla/mux"
"projectforge.dev/projectforge/app"
"projectforge.dev/projectforge/app/controller"
"projectforge.dev/projectforge/app/controller/clib"
"projectforge.dev/projectforge/app/controller/cutil"
"projectforge.dev/projectforge/app/util"
)
func makeRoute(x *mux.Router, method string, path string, f http.HandlerFunc) {
cutil.AddRoute(method, path)
x.HandleFunc(path, f).Methods(method)
}
//nolint:revive
func AppRoutes(as *app.State, logger util.Logger) (http.Handler, error) {
r := mux.NewRouter()
makeRoute(r, http.MethodGet, "/", controller.Home)
makeRoute(r, http.MethodGet, "/healthcheck", clib.Healthcheck)
makeRoute(r, http.MethodGet, "/about", clib.About)
makeRoute(r, http.MethodGet, cutil.DefaultProfilePath, clib.Profile)
makeRoute(r, http.MethodPost, cutil.DefaultProfilePath, clib.ProfileSave)
makeRoute(r, http.MethodGet, cutil.DefaultSearchPath, clib.Search)
themeRoutes(r)
// $PF_SECTION_START(routes)$
moduleRoutes(r)
projectRoutes(r)
makeRoute(r, http.MethodGet, "/testbed", controller.Testbed)
makeRoute(r, http.MethodPost, "/testbed", controller.Testbed)
// $PF_SECTION_END(routes)$
makeRoute(r, http.MethodGet, "/docs", clib.Docs)
makeRoute(r, http.MethodGet, "/docs/{path:.*}", clib.Docs)
makeRoute(r, http.MethodGet, "/admin", clib.Admin)
makeRoute(r, http.MethodGet, "/admin/", clib.Admin)
makeRoute(r, http.MethodPost, "/admin/", clib.Admin)
execRoutes(r)
makeRoute(r, http.MethodGet, "/favicon.ico", clib.Favicon)
makeRoute(r, http.MethodGet, "/robots.txt", clib.RobotsTxt)
makeRoute(r, http.MethodGet, "/assets/{path:.*}", clib.Static)
makeRoute(r, http.MethodOptions, "/", controller.Options)
r.HandleFunc("/", controller.NotFoundAction)
return cutil.WireRouter(r, logger)
}