AssetHelper

package
v1.1.162 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

README

###静态文件打包处理

使用说明

在入口文件 main 中引用

//go:embed Asset
var PublicAsset embed.FS

加入需打包的目录

assetHandler := Helper.AssetHandler("/static/", &PublicAsset, "./Asset/source")

加入http路由

http.HandleFunc("/static/", func(writer http.ResponseWriter, request *http.Request) {
	assetHandler.ServeHTTP(writer, request)
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetHandler

func AssetHandler(prefix string, assets *embed.FS, root string) http.Handler

AssetHandler returns an http.Handler that will serve files from the Assets embed.FS. When locating a file, it will strip the given prefix from the request and prepend the root to the filesystem.

Types

This section is empty.

Jump to

Keyboard shortcuts

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