📌Goa v3 で go:embed を利用する試行錯誤2021/05/03に公開2021/05/084件GoAPIhttpgoatechDiscussionchezgi2021/05/08thanks ikawaha, when embedding web files its encoding was set to plain-text. if you add mime detection based on file extension, it works. in design: Response(func() { Header("length:Content-Length") Header("encoding:Content-Type") }) and in code: return &static.FileResultType{ Length: fi.Size(), Encoding: mime.TypeByExtension(filepath.Ext(fpath)), }, f, nil ikawaha2021/05/08Thank you for commenting on an important point! I have corrected them. 返信を追加Hikaruoo2024/11/18SkipResponseBodyEncodeDecode()の使用ポイントや、embed.FSを活用したディレクトリ指定の詳細な実装が大変参考になります。 アセット埋め込みを活用することで、運用面でも配布が楽になる利点が明確に伝わってきました。このような取り組みは、リリースフローをシンプル化したい開発者にとって有益だと感じます。ありがとうございます。 ikawaha2024/11/19いまは Goa が公式にサポートしているので、もっとシュッと OpenAPI ドキュメントを埋め込んだり出来ます。こちらにサンプルがあります https://github.com/goadesign/examples/tree/master/files 👍 返信を追加
chezgi2021/05/08thanks ikawaha, when embedding web files its encoding was set to plain-text. if you add mime detection based on file extension, it works. in design: Response(func() { Header("length:Content-Length") Header("encoding:Content-Type") }) and in code: return &static.FileResultType{ Length: fi.Size(), Encoding: mime.TypeByExtension(filepath.Ext(fpath)), }, f, nil ikawaha2021/05/08Thank you for commenting on an important point! I have corrected them. 返信を追加
Hikaruoo2024/11/18SkipResponseBodyEncodeDecode()の使用ポイントや、embed.FSを活用したディレクトリ指定の詳細な実装が大変参考になります。 アセット埋め込みを活用することで、運用面でも配布が楽になる利点が明確に伝わってきました。このような取り組みは、リリースフローをシンプル化したい開発者にとって有益だと感じます。ありがとうございます。 ikawaha2024/11/19いまは Goa が公式にサポートしているので、もっとシュッと OpenAPI ドキュメントを埋め込んだり出来ます。こちらにサンプルがあります https://github.com/goadesign/examples/tree/master/files 👍 返信を追加
ikawaha2024/11/19いまは Goa が公式にサポートしているので、もっとシュッと OpenAPI ドキュメントを埋め込んだり出来ます。こちらにサンプルがあります https://github.com/goadesign/examples/tree/master/files 👍
Discussion
thanks ikawaha,
when embedding web files its encoding was set to plain-text.
if you add mime detection based on file extension, it works.
in design:
and in code:
Thank you for commenting on an important point!
I have corrected them.
SkipResponseBodyEncodeDecode()の使用ポイントや、embed.FSを活用したディレクトリ指定の詳細な実装が大変参考になります。アセット埋め込みを活用することで、運用面でも配布が楽になる利点が明確に伝わってきました。このような取り組みは、リリースフローをシンプル化したい開発者にとって有益だと感じます。ありがとうございます。
いまは Goa が公式にサポートしているので、もっとシュッと OpenAPI ドキュメントを埋め込んだり出来ます。こちらにサンプルがあります https://github.com/goadesign/examples/tree/master/files
👍