From 12d12a33dec1d31f487b70f87bc31e80252f327c Mon Sep 17 00:00:00 2001 From: stffabi Date: Wed, 21 Feb 2024 13:40:32 +0100 Subject: [PATCH] [v3, assetServer] Update docs --- mkdocs-website/docs/en/API/fullapi.md | 38 +++++++------------ mkdocs-website/docs/en/development/changes.md | 2 +- mkdocs-website/docs/en/whats-new.md | 4 +- mkdocs-website/docs/zh/development/changes.md | 2 +- mkdocs-website/docs/zh/whats-new.md | 4 +- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/mkdocs-website/docs/en/API/fullapi.md b/mkdocs-website/docs/en/API/fullapi.md index 52ce0c2bf..71d93d9a1 100644 --- a/mkdocs-website/docs/en/API/fullapi.md +++ b/mkdocs-website/docs/en/API/fullapi.md @@ -1205,31 +1205,21 @@ AssetOptions defines the configuration of the AssetServer. ```go type AssetOptions struct { - // FS defines the static assets to be used. A GET request is first tried to be served from this FS. If the FS returns - // `os.ErrNotExist` for that file, the request handling will fallback to the Handler and tries to serve the GET - // request from it. - // - // If set to nil, all GET requests will be forwarded to Handler. - FS fs.FS + // Handler which serves all the content to the WebView. + Handler http.Handler - // Handler will be called for every GET request that can't be served from FS, due to `os.ErrNotExist`. Furthermore all - // non GET requests will always be served from this Handler. - // - // If not defined, the result is the following in cases where the Handler would have been called: - // GET request: `http.StatusNotFound` - // Other request: `http.StatusMethodNotAllowed` - Handler http.Handler - - // Middleware is HTTP Middleware which allows to hook into the AssetServer request chain. It allows to skip the default - // request handler dynamically, e.g. implement specialized Routing etc. - // The Middleware is called to build a new `http.Handler` used by the AssetSever and it also receives the default - // handler used by the AssetServer as an argument. - // - // If not defined, the default AssetServer request chain is executed. - // - // Multiple Middlewares can be chained together with: - // ChainMiddleware(middleware ...Middleware) Middleware - Middleware Middleware + // Middleware is a HTTP Middleware which allows to hook into the AssetServer request chain. It allows to skip the default + // request handler dynamically, e.g. implement specialized Routing etc. + // The Middleware is called to build a new `http.Handler` used by the AssetSever and it also receives the default + // handler used by the AssetServer as an argument. + // + // This middleware injects itself before any of Wails internal middlewares. + // + // If not defined, the default AssetServer request chain is executed. + // + // Multiple Middlewares can be chained together with: + // ChainMiddleware(middleware ...Middleware) Middleware + Middleware Middleware // External URL can be set to a development server URL so that all requests are forwarded to it. This is useful // when using a development server like `vite` or `snowpack` which serves the assets on a different port. diff --git a/mkdocs-website/docs/en/development/changes.md b/mkdocs-website/docs/en/development/changes.md index 8a5377d63..ba125147c 100644 --- a/mkdocs-website/docs/en/development/changes.md +++ b/mkdocs-website/docs/en/development/changes.md @@ -164,7 +164,7 @@ Example: 2: 4021313248, }, Assets: application.AssetOptions{ - FS: assets, + Handler: application.AssetFileServerFS(assets), }, Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, diff --git a/mkdocs-website/docs/en/whats-new.md b/mkdocs-website/docs/en/whats-new.md index a57c2a1e8..ac6ee16c4 100644 --- a/mkdocs-website/docs/en/whats-new.md +++ b/mkdocs-website/docs/en/whats-new.md @@ -25,7 +25,7 @@ func main() { app := application.New(application.Options{ Name: "Multi Window Demo", Assets: application.AssetOptions{ - FS: assets, + Handler: application.AssetFileServerFS(assets), }, }) @@ -243,7 +243,7 @@ func main() { Name: "Events Demo", Description: "A demo of the Events API", Assets: application.AssetOptions{ - FS: assets, + Handler: application.AssetFileServerFS(assets), }, Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, diff --git a/mkdocs-website/docs/zh/development/changes.md b/mkdocs-website/docs/zh/development/changes.md index 7e44c6b31..f830d67ef 100644 --- a/mkdocs-website/docs/zh/development/changes.md +++ b/mkdocs-website/docs/zh/development/changes.md @@ -141,7 +141,7 @@ window.go.main = { 2: 4021313248, }, Assets: application.AssetOptions{ - FS: assets, + Handler: application.AssetFileServerFS(assets), }, Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, diff --git a/mkdocs-website/docs/zh/whats-new.md b/mkdocs-website/docs/zh/whats-new.md index d76837e10..9b175a350 100644 --- a/mkdocs-website/docs/zh/whats-new.md +++ b/mkdocs-website/docs/zh/whats-new.md @@ -24,7 +24,7 @@ func main() { app := application.New(application.Options{ Name: "多窗口演示", Assets: application.AssetOptions{ - FS: assets, + Handler: application.AssetFileServerFS(assets), }, }) @@ -233,7 +233,7 @@ func main() { Name: "Events Demo", Description: "Events API演示", Assets: application.AssetOptions{ - FS: assets, + Handler: application.AssetFileServerFS(assets), }, Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true,