mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 09:56:31 +02:00
35 lines
673 B
Go
35 lines
673 B
Go
//go:build embed_pomerium
|
|
|
|
package ui
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
)
|
|
|
|
// ExtUIFS must be set to provide access to UI dist/ files
|
|
var ExtUIFS fs.FS
|
|
|
|
func openFile(name string) (f fs.File, etag string, err error) {
|
|
if ExtUIFS == nil {
|
|
return nil, "", fmt.Errorf("ui package was incorrectly compiled with embed_pomerium yet no FS was provided")
|
|
}
|
|
f, err = ExtUIFS.Open(name)
|
|
if err != nil {
|
|
return nil, "", fmt.Errorf("open %s: %w", name, err)
|
|
}
|
|
|
|
fi, err := f.Stat()
|
|
if err != nil {
|
|
_ = f.Close()
|
|
return nil, "", err
|
|
}
|
|
|
|
modTime := fi.ModTime()
|
|
if modTime.IsZero() {
|
|
modTime = startTime
|
|
}
|
|
etag = fmt.Sprintf("%x", modTime.UnixNano())
|
|
|
|
return f, etag, nil
|
|
}
|