project folder
->templates
->t.tmpl
->examples
->html
->blocks
->...
->assets
->...
->index.html
im t.tmpl there is call to <link rel="stylesheet" href="./blocks/index.css"> which in turn calls to different static files in examples/html/blocks/ and examples/html/assets
I am using echo with such setup:
e.Static("/i/blocks", "examples/html/blocks")
e.Static("/i/assets", "examples/html/assets")
e.Static("/i/blocks/body/examples/html/assets", "examples/html/assets")
e.Static("/i/blocks/logo/examples/html/assets", "examples/html/assets")
v1 := s.e.Group("/i")
v1.GET("/:page-id", s.handlePageDetails)
it works as intended, BUT
I would like to make it simpler and not hardcoded.
Was hoping to solve it like so:
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
Root: "examples/html",
Browse: true,
IgnoreBase: true,
}))
It seems to work locally, but then it turned out that probably e.Static cached or something, because it stopped working after i restarted IDE during update.
So back to square 1.
At the end want something like this(if it is possible) to work:
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
Root: "examples/html",
Browse: true,
IgnoreBase: true,
Filesystem: http.FS(project.StaticFiles),
}))
where in some file static.go in the root of the project i have
//go:embed examples/html
var StaticFiles embed.FS
Not using Echo is not an option. If this can not be achieved through middleware.StaticWithConfig then other options are welcome as long as it doesn't look like what I have with bunch of e.Static for every path possibilities.
Also. The way it works. So there's a Get request to http://localhost:8080/i/:some-id - it calls on template, template calls on statics, those requests look like i/blocks and such, that is why i'm so specific with e.statics, to remove that /i/ part
<link rel="stylesheet" href="/static/blocks/index.css">instead?e.Static("/static", "examples/html"), then reference to the static resources like this:<link rel="stylesheet" href="/static/blocks/index.css">. Have you considered this solution?