Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticFS embed的路径问题 #92

Open
ismlsmile opened this issue Aug 19, 2022 · 1 comment
Open

StaticFS embed的路径问题 #92

ismlsmile opened this issue Aug 19, 2022 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@ismlsmile
Copy link

ismlsmile commented Aug 19, 2022

之前提的一个无法embed的问题,测试了下确实可以。但现在遇到一个embed的路径问题。
假设html的目录是static,目录下有index.html和main.js文件

//go:embed static
var embAssets embed.FS

r.StaticFS("/", http.FS(embAssets))

浏览器访问时需要输入:http://127.0.0.1:8080/static/index.html 但index.html中一般引入js的路径是http://127.0.0.1:8080/main.js 导致无法访问。所以希望在StaticFS中,能够把"static"这一层目录处理掉

@inhere inhere self-assigned this Aug 19, 2022
@inhere
Copy link
Member

inhere commented Aug 21, 2022

这个路径是 FS 控制的,大概翻了下,没找到怎么去掉一部分前缀路径

@inhere inhere added the question Further information is requested label Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants