MCPcopy Index your code
hub / github.com/dreamsofcode-io/zenstats / loadRoutes

Method loadRoutes

internal/app/routes.go:27–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27func (a *App) loadRoutes() (http.Handler, error) {
28 tmpl, err := template.New("").ParseFS(a.files, "templates/*")
29 if err != nil {
30 return nil, fmt.Errorf("failed to parse templates: %w", err)
31 }
32
33 static, err := fs.Sub(a.files, "static")
34 if err != nil {
35 return nil, fmt.Errorf("failed to subdir static: %w", err)
36 }
37
38 // Create a new router
39 router := http.NewServeMux()
40
41 // This is the static fileserver.
42 router.Handle("GET /static/", http.StripPrefix("/static", http.FileServerFS(static)))
43
44 a.loadPages(router, tmpl)
45
46 // Create a middleware chain from the Chain function of the
47 // middleware package
48 chain := middleware.Chain(
49 middleware.Logging(a.logger),
50 )
51
52 return chain(router), nil
53}

Callers 1

StartMethod · 0.95

Calls 3

loadPagesMethod · 0.95
ChainFunction · 0.92
LoggingFunction · 0.92

Tested by

no test coverage detected