Compare commits
3 Commits
e42f307bd1
...
9d5fbca929
Author | SHA1 | Date | |
---|---|---|---|
9d5fbca929 | |||
e341d2f166 | |||
444c725fc6 |
@ -9,4 +9,6 @@ services:
|
|||||||
- ./dev/templates:/templates:ro
|
- ./dev/templates:/templates:ro
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
tmpfs:
|
||||||
|
- /tmp
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
10
handlers.go
10
handlers.go
@ -6,12 +6,12 @@ import (
|
|||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"text/template"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Application struct {
|
type Application struct {
|
||||||
@ -119,10 +119,18 @@ func (app *Application) indexHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
".rst": true,
|
".rst": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
videoExtensions := map[string]bool{
|
||||||
|
".mkv": true,
|
||||||
|
}
|
||||||
|
|
||||||
if textExtensions[ext] {
|
if textExtensions[ext] {
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if videoExtensions[ext] {
|
||||||
|
w.Header().Set("Content-Type", "video/mp4")
|
||||||
|
}
|
||||||
|
|
||||||
http.ServeFile(w, r, path)
|
http.ServeFile(w, r, path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user