Skip to content

Commit

Permalink
Removed configuration for static and static_root since it is hard-cod…
Browse files Browse the repository at this point in the history
…ed in glob patterns
  • Loading branch information
akclace committed May 10, 2024
1 parent 6245eca commit 0b84682
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ func NewApp(sourceFS *appfs.SourceFs, workFS *appfs.WorkFs, logger *types.Logger

funcMap := sprig.FuncMap()
funcMap["static"] = func(name string) string {
staticPath := path.Join(newApp.Config.Routing.StaticDir, name)
staticPath := path.Join("static", name)
fullPath := path.Join(newApp.Path, sourceFS.HashName(staticPath))
return fullPath
}
funcMap["fileNonEmpty"] = func(name string) bool {
staticPath := path.Join(newApp.Config.Routing.StaticDir, name)
staticPath := path.Join("static", name)
fi, err := sourceFS.Stat(staticPath)
if err != nil {
return false
Expand Down
4 changes: 0 additions & 4 deletions internal/app/apptype/appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ type AppConfig struct {
type RouteConfig struct {
TemplateLocations []string `json:"template_locations"`
BaseTemplates string `json:"base_templates"`
StaticDir string `json:"static_dir"`
StaticRootDir string `json:"static_root_dir"`
PushEvents bool `json:"push_events"`
EarlyHints bool `json:"early_hints"`
}
Expand All @@ -30,8 +28,6 @@ func NewAppConfig() *AppConfig {
Routing: RouteConfig{
TemplateLocations: []string{"*.go.html"},
BaseTemplates: "base_templates",
StaticDir: "static",
StaticRootDir: "static_root",
PushEvents: false,
EarlyHints: true,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (a *App) initRouter() error {

// Mount static dir
if !rootWildcard {
staticPattern := path.Join("/", a.Config.Routing.StaticDir, "*")
staticPattern := path.Join("/", "static", "*")
router.Handle(staticPattern, http.StripPrefix(a.Path, appfs.FileServer(a.sourceFS)))
}

Expand Down
2 changes: 0 additions & 2 deletions tests/testapp/config_gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"*.go.html"
],
"base_templates": "base_templates",
"static_dir": "static",
"static_root_dir": "static_root",
"push_events": false,
"early_hints": true
},
Expand Down

0 comments on commit 0b84682

Please sign in to comment.