Skip to content
Discussion options

You must be logged in to vote

Use assetserver.Options.Middleware to dispatch the API prefix before calling Wails' default handler.

Handler is a fallback for GET requests that are absent from Assets; a matching static file therefore wins. Middleware receives the default handler as next and can decide whether to call it.

For example, with assets as your existing filesystem:

api := http.NewServeMux()
api.HandleFunc("/api/health", func(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json")
    _, _ = w.Write([]byte("{\"ok\":true}"))
})

assetOptions := &assetserver.Options{
    Assets: assets,
    Middleware: func(next http.Handler) http.Handler {
        return http.HandlerFunc(func

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by felixgrov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants