Skip to content

Commit

Permalink
Merge pull request #32 from Turboman3000/master
Browse files Browse the repository at this point in the history
Add download mode
  • Loading branch information
TheDevMinerTV authored Jan 6, 2024
2 parents ddfb59b + febe6c2 commit 410b9a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Additionally, you can add the following flags:
-log-requests # Log requests (this will slow down the server by ~40%)
-index <file> # The file to serve when the path ends in `/` (default=index.html)
-spa # Make all 404 pages the index file, useful for SPA apps that use client side routing
-download # Enable downloading files
```

You can just add these to the end of the `docker run` command.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
fLogRequests = flag.Bool("log-requests", false, "Log requests to stdout")
fSPA = flag.Bool("spa", false, "Serve index.html for 404 pages (for SPA apps)")
fIndex = flag.String("index", "index.html", "Index file relative from the files path")
fDownload = flag.Bool("download", false, "Enables direct Download for Served Files")
)

func main() {
Expand Down Expand Up @@ -49,6 +50,10 @@ func main() {
app.Use(logger.New())
}

if *fDownload {
log.Printf("Enabling downloads")
}

if *fCompressLevel > 0 {
log.Printf("Enabling compression: %d", *fCompressLevel)

Expand All @@ -65,7 +70,7 @@ func main() {

app.Static("/", *fFilePath, fiber.Static{
Compress: true,
Download: false,
Download: *fDownload,
CacheDuration: *fCacheDuration,
MaxAge: int((*fCacheDuration).Seconds()),
ByteRange: true,
Expand Down

0 comments on commit 410b9a1

Please sign in to comment.