Skip to content
Snippets Groups Projects
Verified Commit 04828ff3 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

fix: automatically add mime type headers to static files

parent d7c3db94
No related branches found
No related tags found
No related merge requests found
Pipeline #2822 passed
...@@ -8,8 +8,10 @@ import ( ...@@ -8,8 +8,10 @@ import (
"github.com/hibiken/asynqmon" "github.com/hibiken/asynqmon"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"log" "log"
"mime"
"net/http" "net/http"
"os" "os"
"path/filepath"
) )
func main() { func main() {
...@@ -43,6 +45,12 @@ func main() { ...@@ -43,6 +45,12 @@ func main() {
PayloadFormatter: asynqmon.PayloadFormatterFunc(shared.FormatPayload), PayloadFormatter: asynqmon.PayloadFormatterFunc(shared.FormatPayload),
ResultFormatter: asynqmon.ResultFormatterFunc(shared.FormatResult), ResultFormatter: asynqmon.ResultFormatterFunc(shared.FormatResult),
}) })
http.Handle(monitor.RootPath()+"/static/",
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", mime.TypeByExtension(filepath.Ext(r.URL.Path)))
monitor.ServeHTTP(w, r)
}),
)
http.Handle(monitor.RootPath()+"/", monitor) http.Handle(monitor.RootPath()+"/", monitor)
http.Handle("/upload/", pageUpload(pageContext)) http.Handle("/upload/", pageUpload(pageContext))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment