mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-24 22:47:14 +02:00
assets: use embed instead of statik (#1960)
* assets: use embed instead of statik * remove empty line * maybe fix precommit
This commit is contained in:
parent
92c3a4a56c
commit
b6ec01f377
15 changed files with 78 additions and 125 deletions
|
@ -1,16 +1,12 @@
|
|||
package controlplane
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rakyll/statik/fs"
|
||||
|
||||
// include luascripts source code
|
||||
_ "github.com/pomerium/pomerium/internal/controlplane/luascripts"
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/rakyll/statik -m -src=./luascripts -include=*.lua -p luascripts -ns luascripts
|
||||
//go:generate go fmt ./luascripts/statik.go
|
||||
//go:embed luascripts
|
||||
var luaFS embed.FS
|
||||
|
||||
var luascripts struct {
|
||||
ExtAuthzSetCookie string
|
||||
|
@ -20,28 +16,23 @@ var luascripts struct {
|
|||
}
|
||||
|
||||
func init() {
|
||||
hfs, err := fs.NewWithNamespace("luascripts")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fileToField := map[string]*string{
|
||||
"/clean-upstream.lua": &luascripts.CleanUpstream,
|
||||
"/ext-authz-set-cookie.lua": &luascripts.ExtAuthzSetCookie,
|
||||
"/remove-impersonate-headers.lua": &luascripts.RemoveImpersonateHeaders,
|
||||
"/fix-misdirected.lua": &luascripts.FixMisdirected,
|
||||
"luascripts/clean-upstream.lua": &luascripts.CleanUpstream,
|
||||
"luascripts/ext-authz-set-cookie.lua": &luascripts.ExtAuthzSetCookie,
|
||||
"luascripts/remove-impersonate-headers.lua": &luascripts.RemoveImpersonateHeaders,
|
||||
"luascripts/fix-misdirected.lua": &luascripts.FixMisdirected,
|
||||
}
|
||||
|
||||
err = fs.Walk(hfs, "/", func(p string, fi os.FileInfo, err error) error {
|
||||
err := fs.WalkDir(luaFS, "luascripts", func(p string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
bs, err := fs.ReadFile(hfs, p)
|
||||
bs, err := luaFS.ReadFile(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue