|
|
|
|
|
by andreygrehov
1451 days ago
|
|
Congrats! > One Binary > Build frontend apps along with your backend and ship everything in a single binary. I'm doing something similar and love it. Do you embed the entire `public` directory and then traverse the embed.FS to access the files in memory? |
|
I've done this in Rust before, I'm sharing it here as I'm assuming that Go has something similar.
I'm basically hard-coding the paths in the backend to also serve static assets, and embed the bytes of the asset at compile time, so when it runs, it's just serving it straight from memory. Here how it looks for style.css for example: https://codeberg.org/ditzes/ditzes/src/branch/master/src-tau...
It'd be trivial to move the structure to something like a map instead, where the URL is the key and another map where bytes, headers and such is stored. Mostly I didn't, because I'm just embedding few amount of files.