2014-02-06 06:07
浏览 186


I have a quick question about serving files in Go. There is the great timesaving FileServer handler, but for my use case, I only have 2 or 3 files (js and css) that go with my app and I dont want to complicate the deployment to have to think about those.

Do you think there is an easy way to build those couple of files into the binary and serve them from there. For example base64 encode the data of the files as constants and server the files from the constants. This would work in its most simple form, but I dont want to go through the pain of doing everything that a file server does (headers, expiries, mime-types, etc) on my own. So would there be an easy way to bake those static files into the binary in some form and serve them that way?

图片转代码服务由CSDN问答提供 功能建议

我有一个关于在Go中提供文件的快速问题。 有一个节省时间的FileServer处理程序,但是对于我的用例来说,我的应用程序只有2或3个文件(js和css),我不想让部署变得复杂而不得不考虑这些。

您是否认为有一种简单的方法可以将这两个文件构建为二进制文件并从那里提供文件。 例如,base64将文件的数据编码为常量,然后从常量中存储文件。 这将以最简单的形式工作,但是我不想自己做文件服务器所做的所有事情(标头,到期,mime类型等)。 那么,有没有一种简单的方法可以将这些静态文件以某种形式烘焙到二进制文件中并以这种方式提供服务?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题