parent
c2f60493a6
commit
04293b1595
@ -18,8 +18,10 @@ package static
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
const StaticResource = "/static/"
|
const StaticResource = "/static/"
|
||||||
@ -46,6 +48,12 @@ func HandleRequest(w http.ResponseWriter, u *url.URL) error {
|
|||||||
return fmt.Errorf("unknown static resource %q", resource)
|
return fmt.Errorf("unknown static resource %q", resource)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set Content-Type if we were able to detect it.
|
||||||
|
contentType := mime.TypeByExtension(path.Ext(resource))
|
||||||
|
if contentType != "" {
|
||||||
|
w.Header().Set("Content-Type", contentType)
|
||||||
|
}
|
||||||
|
|
||||||
_, err := w.Write([]byte(content))
|
_, err := w.Write([]byte(content))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user