You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
First of all, thanks for creating this! It works well and the API is clean and simple.
I used it to bundle wasm and js into an example app so that a server and all content is bundled into the app. Some of my content is generated dynamically, so delegating everything to
http.FileServer(FS(false))
didn't seem workable. I ended up writing handler functions like the following to allow setting proper content headers. Seems to work very well, though I don't know if that's the cleanest possible way to code it.
// fsSendStatic serves the requested file from the ESC FS.
func fsSendStatic(w http.ResponseWriter, r *http.Request) {
_, err := w.Write(FSMustByte(false, r.URL.Path))
if err != nil {
log.Fatalf("Writing file %s returned error: %v", r.URL.Path, err)
}
}
// fsSendStaticJS serves the requested javascript file from the ESC FS.
func fsSendStaticJS(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/javascript")
fsSendStatic(w, r)
}
// fsSendStaticWasm serves the requested WebAssembly file from the ESC FS.
func fsSendStaticWasm(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/wasm")
fsSendStatic(w, r)
}
It took a bit of trial and error to get it working. Just wondering if it might save others some time if the README included an example showing how to serve a mixture of static and dynamic content.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
First of all, thanks for creating this! It works well and the API is clean and simple.
I used it to bundle wasm and js into an example app so that a server and all content is bundled into the app. Some of my content is generated dynamically, so delegating everything to
didn't seem workable. I ended up writing handler functions like the following to allow setting proper content headers. Seems to work very well, though I don't know if that's the cleanest possible way to code it.
It took a bit of trial and error to get it working. Just wondering if it might save others some time if the README included an example showing how to serve a mixture of static and dynamic content.
The text was updated successfully, but these errors were encountered: