mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v2] Add support for AssetsHandler (#1325)
* [website] Fix devserver default value doc
* [v2] Add support for AssetsHandler
AssetsHandler is a http.Handler delegate, which gets called
as a fallback for all Non-GET requests and for GET requests
for which the Assets didn’t find the file.
Known Limitations on Linux:
- All requests are GET requests
- No request headers
- No request body
- No response status code, only StatusOK will be returned
- No response headers
Known Limitations on Windows:
- Request body is leaking memory. Seems to be a bug in
WebView2, investigation angoing.
Most of these limitations on Linux will be fixed in the future with
adding support for Webkit2Gtk 2.36.0+.
* [v2, linux] Add response streaming support
The complete response won’t be held anymore in memory and will
be streamed to WebKit2.
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -84,12 +83,16 @@ func (d *DevWebServer) Run(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if externalURL.Host == "" {
|
||||
return fmt.Errorf("Invalid frontend:dev:serverUrl missing protocol scheme?")
|
||||
}
|
||||
|
||||
waitCb := func() { d.LogDebug("Waiting for frontend DevServer '%s' to be ready", externalURL) }
|
||||
if !checkPortIsOpen(externalURL.Host, time.Minute, waitCb) {
|
||||
d.logger.Error("Timeout waiting for frontend DevServer")
|
||||
}
|
||||
|
||||
assetHandler = httputil.NewSingleHostReverseProxy(externalURL)
|
||||
assetHandler = newExternalDevServerAssetHandler(d.logger, externalURL, d.appoptions.AssetsHandler)
|
||||
}
|
||||
|
||||
// Setup internal dev server
|
||||
@@ -103,7 +106,7 @@ func (d *DevWebServer) Run(ctx context.Context) error {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
d.server.GET("/*", func(c echo.Context) error {
|
||||
d.server.Any("/*", func(c echo.Context) error {
|
||||
assetServer.ServeHTTP(c.Response(), c.Request())
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user