Skip to content

Commit

Permalink
fixed the dsiplay of file for the http server
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacwein committed May 7, 2024
1 parent 68e98b2 commit d86ba34
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/telebroad/fileserver/users"
"io/fs"
"log/slog"
"mime"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -125,6 +126,8 @@ func main() {

// http file server support read and write and delete files
router := http.NewServeMux()
// add mime types
addMimTypes()

router.Handle("/static/{pathname...}", httphandler.NewFileServerHandler("/static", localFS, u))
httpServer := &httphandler.Server{
Expand Down Expand Up @@ -283,3 +286,7 @@ func GetEnv(logger *slog.Logger) (env *Environment, err error) {

return
}
func addMimTypes() {
mime.AddExtensionType(".wav", "audio/wave")
mime.AddExtensionType(".wav", "audio/wav")
}

0 comments on commit d86ba34

Please sign in to comment.