Documentation ¶
Index ¶
- Variables
- type Statik
- type StatikDirInfo
- type StatikFS
- func (m *StatikFS) GetStatik(path string) (Statik, error)
- func (m *StatikFS) Mkdir(_ context.Context, _ string, _ os.FileMode) error
- func (m *StatikFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)
- func (m *StatikFS) RemoveAll(_ context.Context, _ string) error
- func (m *StatikFS) Rename(_ context.Context, _, _ string) error
- func (m *StatikFS) Stat(_ context.Context, name string) (os.FileInfo, error)
- type StatikFileInfo
Constants ¶
This section is empty.
Variables ¶
var StatikCachingTime = 5 * time.Minute
Functions ¶
This section is empty.
Types ¶
type Statik ¶
type Statik struct { StatikDirInfo Directories []StatikDirInfo `json:"directories"` Files []StatikFileInfo `json:"files"` }
type StatikDirInfo ¶
type StatikDirInfo struct { Url string `json:"url"` Time time.Time `json:"time"` GeneratedAt time.Time `json:"generated_at"` NameRaw string `json:"name"` Path string `json:"path"` SizeRaw string `json:"size"` }
StatikDirInfo represents a directory in Statik
func (StatikDirInfo) IsDir ¶
func (d StatikDirInfo) IsDir() bool
func (StatikDirInfo) ModTime ¶
func (d StatikDirInfo) ModTime() time.Time
func (StatikDirInfo) Mode ¶
func (d StatikDirInfo) Mode() iofs.FileMode
func (StatikDirInfo) Name ¶
func (d StatikDirInfo) Name() string
func (StatikDirInfo) Size ¶
func (d StatikDirInfo) Size() int64
Size implements fs.FileInfo for StatikDirInfo and Statik
func (StatikDirInfo) Sys ¶
func (d StatikDirInfo) Sys() any
type StatikFS ¶
type StatikFS struct {
// contains filtered or unexported fields
}
StatikFS represents a virtual filesystem that is backed by a statik.json files in a remote server.
cache is a map from path to Statik, where path is the path of the directory containing the statik.json file. cacheLock is a RW mutex that protects cache. It is used by GetStatik and cacheStatik.
func NewStatikFS ¶
NewStatikFS returns a new StatikFS that is backed by a statik.json file in the remote server at base url.
The returned StatikFS is read-only. The returned StatikFS is goroutine-safe.
func (*StatikFS) GetStatik ¶
GetStatik returns the Statik struct for the statik.json file in the directory specified by path.
If the statik.json file is not cached, it is fetched from the remote server, cached and returned.
The function is safe for concurrent use, as it uses a RW mutex to protect the cache.
func (*StatikFS) OpenFile ¶
func (m *StatikFS) OpenFile( ctx context.Context, name string, flag int, perm os.FileMode, ) (webdav.File, error)
OpenFile implements webdav.FileSystem for StatikFS.
type StatikFileInfo ¶
type StatikFileInfo struct { NameRaw string `json:"name"` Path string `json:"path"` Url string `json:"url"` Mime string `json:"mime"` SizeRaw string `json:"size"` Time time.Time `json:"time"` }
func (StatikFileInfo) IsDir ¶
func (f StatikFileInfo) IsDir() bool
func (StatikFileInfo) ModTime ¶
func (f StatikFileInfo) ModTime() time.Time
func (StatikFileInfo) Mode ¶
func (f StatikFileInfo) Mode() fs.FileMode
func (StatikFileInfo) Name ¶
func (f StatikFileInfo) Name() string
func (StatikFileInfo) Size ¶
func (f StatikFileInfo) Size() int64
Size implements fs.FileInfo for StatikFileInfo
func (StatikFileInfo) Sys ¶
func (f StatikFileInfo) Sys() any