mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3, assetServer] Update docs
This commit is contained in:
parent
1956f95f9f
commit
12d12a33de
5 changed files with 21 additions and 31 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ Example:
|
|||
2: 4021313248,
|
||||
},
|
||||
Assets: application.AssetOptions{
|
||||
FS: assets,
|
||||
Handler: application.AssetFileServerFS(assets),
|
||||
},
|
||||
Mac: application.MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ window.go.main = {
|
|||
2: 4021313248,
|
||||
},
|
||||
Assets: application.AssetOptions{
|
||||
FS: assets,
|
||||
Handler: application.AssetFileServerFS(assets),
|
||||
},
|
||||
Mac: application.MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue