gob fetcher for wasm example
This commit is contained in:
@@ -40,6 +40,7 @@ type Config struct {
|
||||
Build func() ([]byte, error) // (re)build the wasm bundle; combined output on failure
|
||||
Render func(path string) (inner string, ok bool) // SSR the #app inner HTML for a route (ok=false => client-rendered)
|
||||
Document func(inner string) string // wrap #app inner HTML in a full HTML document
|
||||
Handle func(mux *http.ServeMux) // optional: register extra routes (e.g. app API endpoints)
|
||||
}
|
||||
|
||||
// Serve builds once (in watch mode), wires the routes, and blocks serving.
|
||||
@@ -70,6 +71,9 @@ func Serve(cfg Config) error {
|
||||
}
|
||||
|
||||
mux.HandleFunc("POST /rsc", rsc.Handler) // server components
|
||||
if cfg.Handle != nil {
|
||||
cfg.Handle(mux) // app-registered routes (API endpoints, etc.)
|
||||
}
|
||||
mux.HandleFunc("/", rootHandler(cfg))
|
||||
|
||||
log.Printf("serving %q on http://localhost%s", cfg.Dir, cfg.Addr)
|
||||
|
||||
Reference in New Issue
Block a user