Skip to content

LocalDir not working as shown in the examples. #846

Closed
@voxeljorge

Description

@voxeljorge

From the documentation it seems LocalDir is intended to allow you to specify some directory on the local filesystem to serve under web/ for static assets. There is an example for this showing /tmp/web as an example destination but this does not seem to work. Here's my main.go:

package main

import (
	"log"
	"net/http"

	"github.com/maxence-charriere/go-app/v9/pkg/app"
)

type hello struct {
	app.Compo
}

func (h *hello) Render() app.UI {
	return app.H1().Text("Hello World!")
}

func main() {
	app.Route("/", &hello{})
	app.RunWhenOnBrowser()

	http.Handle("/", &app.Handler{
		Name:        "Hello",
		Description: "An Hello World! example",
		Resources:   app.LocalDir("/tmp/goappweb"),
	})

	if err := http.ListenAndServe(":8000", nil); err != nil {
		log.Fatal(err)
	}
}

I ran the following to build the app:

mkdir -p /tmp/goappweb
GOARCH=wasm GOOS=js go build -o /tmp/goappweb/app.wasm .

Here's a screenshot of the result in my browser.
Screenshot 2023-07-20 at 11 37 58 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions