Skip to content

Commit

Permalink
feat: add FS and SkipCache fields to StaticFS type
Browse files Browse the repository at this point in the history
  • Loading branch information
savsgio committed Nov 17, 2023
1 parent 3979c7b commit 824eea0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func (r *Router) StaticCustom(url string, fs *StaticFS) *Path {
url = strings.TrimSuffix(url, "/")

ffs := &fasthttp.FS{
FS: fs.FS,
Root: fs.Root,
AllowEmptyRoot: fs.AllowEmptyRoot,
IndexNames: fs.IndexNames,
Expand All @@ -352,6 +353,7 @@ func (r *Router) StaticCustom(url string, fs *StaticFS) *Path {
CompressBrotli: fs.CompressBrotli,
CompressRoot: fs.CompressRoot,
AcceptByteRange: fs.AcceptByteRange,
SkipCache: fs.SkipCache,
CacheDuration: fs.CacheDuration,
CompressedFileSuffix: fs.CompressedFileSuffix,
CompressedFileSuffixes: fs.CompressedFileSuffixes,
Expand Down
9 changes: 9 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package atreugo
import (
"crypto/tls"
"io"
"io/fs"
"net"
"os"
"time"
Expand Down Expand Up @@ -377,6 +378,9 @@ type Config struct { // nolint:maligned
type StaticFS struct {
noCopy nocopy.NoCopy // nolint:structcheck,unused

// FS is filesystem to serve files from. eg: embed.FS os.DirFS
FS fs.FS

// Path to the root directory to serve files from.
Root string

Expand Down Expand Up @@ -448,6 +452,11 @@ type StaticFS struct {
// "Cannot open requested path"
PathNotFound View

// SkipCache if true, will cache no file handler.
//
// By default is false.
SkipCache bool

// Expiration duration for inactive file handlers.
//
// FSHandlerCacheDuration is used by default.
Expand Down

0 comments on commit 824eea0

Please sign in to comment.