Reputation: 31
I have been dealing with an issue with the static files in the application I'm building in go using Echo framework, I can not get the files to load, I only get 404 for the static files.
I have this in a router that returns content and a html file path to be rendered:
e.Static("/resources", "resources")
e.Static("/css", "css")
e.Static("/js", "js")
My file tree looks like this:
-repo
--cmd
---app
---main.go
--css
---all css files
--js
---all js files
--resources
---all resources
--internal
---pageRouter
----pageRouter.go (containing the above code)
For the html files I tried to import the files relative to the static function, and relative to current location and still get 404.
Clearing the cash memory did not help.
The error from the logger middleware includes status code 404 and "uri":"/css/index.css" which is the correct path.
I tried everything from moving around the files, to other file servers and I can not get it to work.
Upvotes: 1
Views: 40
Reputation: 31
Solved.
For others having the same problem, use this insted:
e.Use(middleware.Static())
and add the relative path to the static content folder.
Upvotes: 2