Documentation ¶
Overview ¶
Code from https://github.com/erikdubbelboer/ringqueue
The MIT License (MIT)
Copyright (c) 2015 Erik Dubbelboer ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- func FindEmbedRootPath(fileSystem embed.FS) (string, error)
- func FindPathToFile(fileSystem fs.FS, file string) (string, error)
- func GetDevServerURL() string
- func GetMimetype(filename string, data []byte) string
- func GetStartURL(userURL string) (string, error)
- func NewDefaultAssetHandler(options *Options) (http.Handler, error)
- type AssetServer
- type Middleware
- type Options
- type RuntimeHandler
Constants ¶
const ( HeaderHost = "Host" HeaderContentType = "Content-Type" HeaderContentLength = "Content-Length" HeaderUserAgent = "User-Agent" // TODO: Is this needed? HeaderCacheControl = "Cache-Control" HeaderUpgrade = "Upgrade" WailsUserAgentValue = "wails.io" )
Variables ¶
This section is empty.
Functions ¶
func FindEmbedRootPath ¶
FindEmbedRootPath finds the root path in the embed FS. It's the directory which contains all the files.
func GetDevServerURL ¶
func GetDevServerURL() string
func GetMimetype ¶
func GetStartURL ¶
Types ¶
type AssetServer ¶
type AssetServer struct {
// contains filtered or unexported fields
}
func NewAssetServer ¶
func NewAssetServer(options *Options) (*AssetServer, error)
func (*AssetServer) AddPluginScript ¶
func (a *AssetServer) AddPluginScript(pluginName string, script string)
func (*AssetServer) LogDetails ¶
func (a *AssetServer) LogDetails()
func (*AssetServer) ServeHTTP ¶
func (a *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*AssetServer) ServeWebViewRequest ¶
func (a *AssetServer) ServeWebViewRequest(req webview.Request)
ServeWebViewRequest processes the HTTP Request asynchronously by faking a golang HTTP Server. The request will be finished with a StatusNotImplemented code if no handler has written to the response. The AssetServer takes ownership of the request and the caller mustn't close it or access it in any other way.
type Middleware ¶
Middleware defines a HTTP middleware that can be applied to the AssetServer. The handler passed as next is the next handler in the chain. One can decide to call the next handler or implement a specialized handling.
func ChainMiddleware ¶
func ChainMiddleware(middleware ...Middleware) Middleware
ChainMiddleware allows chaining multiple middlewares to one middleware.
type Options ¶
type Options struct { // Assets defines the static assets to be used. A GET request is first tried to be served from this Assets. If the Assets 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. Assets fs.FS // Handler will be called for every GET request that can't be served from Assets, 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 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. // // If not defined, the default AssetServer request chain is executed. // // Multiple Middlewares can be chained together with: // ChainMiddleware(middleware ...Middleware) Middleware Middleware Middleware // Logger is the logger used by the AssetServer. If not defined, no logging will be done. Logger *slog.Logger // RuntimeHandler is the handler used for the runtime calls. RuntimeHandler http.Handler // GetCapabilities returns the capabilities of the runtime GetCapabilities func() []byte // GetFlags returns the application flags GetFlags func() []byte }
Options defines the configuration of the AssetServer.
type RuntimeHandler ¶
type RuntimeHandler interface {
HandleRuntimeCall(w http.ResponseWriter, r *http.Request)
}