Documentation
¶
Index ¶
- func AssetCSSLinks(jsEntrySrc, devStylesheetSrc string) template.HTML
- func AssetFS() *assetfs.LayeredFS
- func AssetNameFromHashedPath(hashedPath string) string
- func AssetURI(srcPath 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 AssetCSSLinks ¶ added in v1.27.0
AssetCSSLinks renders the <link> tags for a JS entry's stylesheets: the entry's CSS plus the CSS of every statically-imported chunk. Dev links devStylesheetSrc and lets the JS module inject the rest.
func AssetNameFromHashedPath ¶ added in v1.27.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.27.0
AssetURI resolves a frontend asset by its source path (the Vite manifest key, e.g. "web_src/js/index.ts"). Dev mode serves the source file; production resolves the hashed output.
func BuiltinAssets ¶ added in v1.27.0
func CustomAssets ¶ added in v1.27.0
func DetectWellKnownMimeType ¶ added in v1.27.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.27.0
func FileHandlerFunc() http.HandlerFunc
FileHandlerFunc implements the static handler for serving files in "public" assets
func IsViteDevMode ¶ added in v1.27.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.27.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.