Compare commits

..

3 Commits

Author SHA1 Message Date
9d5fbca929 fix: mkv videos not playing on browser 2024-09-19 15:47:24 -03:00
e341d2f166 fix: limited /tmp space inside container
causes big uploads to not go through
2024-09-19 15:39:11 -03:00
444c725fc6 fix: change to html/template for more security 2024-09-19 15:38:43 -03:00
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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
} }