Documentation
¶
Index ¶
- func AssetFS() *assetfs.LayeredFS
- func AssetNameFromHashedPath(hashedPath string) string
- func AssetURI(originPath string) string
- func AssetsCors() func(next http.Handler) http.Handler
- func BuiltinAssets() *assetfs.Layer
- func CustomAssets() *assetfs.Layer
- func DetectWellKnownMimeType(ext string) string
- func FileHandlerFunc() http.HandlerFunc
- func IsViteDevMode() bool
- func ViteDevMiddleware(next http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetNameFromHashedPath ¶ added in v1.26.0
AssetNameFromHashedPath returns the asset entry name for a given hashed asset path. Example: returns "theme-gitea-dark" for "css/theme-gitea-dark.CyAaQnn5.css". Returns empty string if the path is not found in the manifest.
func AssetURI ¶ added in v1.26.0
AssetURI returns the URI for a frontend asset. It may return a relative path or a full URL depending on the StaticURLPrefix setting. In Vite dev mode, known entry points are mapped to their source paths so the reverse proxy serves them from the Vite dev server. In production, it resolves the content-hashed path from the manifest.
func BuiltinAssets ¶ added in v1.20.0
func CustomAssets ¶ added in v1.20.0
func DetectWellKnownMimeType ¶ added in v1.26.0
DetectWellKnownMimeType will return the mime-type for a well-known file ext name The purpose of this function is to bypass the unstable behavior of Golang's mime.TypeByExtension mime.TypeByExtension would use OS's mime-type config to overwrite the well-known types (see its document). If the user's OS has incorrect mime-type config, it would make Gitea can not respond a correct Content-Type to browsers. For example, if Gitea returns `text/plain` for a `.js` file, the browser couldn't run the JS due to security reasons. DetectWellKnownMimeType makes the Content-Type for well-known files stable.
func FileHandlerFunc ¶ added in v1.21.0
func FileHandlerFunc() http.HandlerFunc
FileHandlerFunc implements the static handler for serving files in "public" assets
func IsViteDevMode ¶ added in v1.26.0
func IsViteDevMode() bool
IsViteDevMode returns true if the Vite dev server port file exists and the server is alive
func ViteDevMiddleware ¶ added in v1.26.0
ViteDevMiddleware proxies matching requests to the Vite dev server. It is registered as middleware in non-production mode and lazily discovers the Vite dev server port from the port file written by the viteDevServerPortPlugin. It is needed because there are container-based development, only Gitea web server's port is exposed.
Types ¶
This section is empty.