public

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 23 Imported by: 67

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetFS added in v1.20.0

func AssetFS() *assetfs.LayeredFS

func AssetNameFromHashedPath added in v1.26.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.26.0

func AssetURI(originPath string) string

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

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

func BuiltinAssets added in v1.20.0

func BuiltinAssets() *assetfs.Layer

func CustomAssets added in v1.20.0

func CustomAssets() *assetfs.Layer

func DetectWellKnownMimeType added in v1.26.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.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

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