public

package
v1.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetCSSLinks(jsEntrySrc, devStylesheetSrc string) template.HTML

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 AssetFS added in v1.27.0

func AssetFS() *assetfs.LayeredFS

func AssetNameFromHashedPath added in v1.27.0

func AssetNameFromHashedPath(hashedPath string) string

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

func AssetURI(srcPath string) string

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 AssetsCors added in v1.27.0

func AssetsCors() func(next http.Handler) http.Handler

func BuiltinAssets added in v1.27.0

func BuiltinAssets() *assetfs.Layer

func CustomAssets added in v1.27.0

func CustomAssets() *assetfs.Layer

func DetectWellKnownMimeType added in v1.27.0

func DetectWellKnownMimeType(ext string) string

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

func ViteDevMiddleware(next http.Handler) http.Handler

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL