mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 01:19:12 +08:00

* [v2] Consolidate AssetServers * [v2] Support starturl for webview on linux and darwin * [v2] Add support for frontend DevServer * [v2] Activate frontend DevServer in svelte template * [website] Add bleeding edge guide for PRs * DoNotMerge: Bump Version for testing Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
34 lines
729 B
Go
34 lines
729 B
Go
//go:build dev
|
|
// +build dev
|
|
|
|
package assetserver
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
|
|
)
|
|
|
|
/*
|
|
The assetserver for dev serves assets from disk.
|
|
It injects a websocket based IPC script into `index.html`.
|
|
*/
|
|
func NewBrowserAssetServer(ctx context.Context, handler http.Handler, bindingsJSON string) (*AssetServer, error) {
|
|
result, err := NewAssetServerWithHandler(ctx, handler, bindingsJSON)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
result.appendSpinnerToBody = true
|
|
result.ipcJS = func(req *http.Request) []byte {
|
|
if strings.Contains(req.UserAgent(), WailsUserAgentValue) {
|
|
return runtime.DesktopIPC
|
|
}
|
|
return runtime.WebsocketIPC
|
|
}
|
|
|
|
return result, nil
|
|
}
|