A web blog and personal homepage engine written in Go.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
706 B

package responses
import (
// SendFile sends a file from bindata or the user root.
func SendFile(w http.ResponseWriter, r *http.Request, path string) {
mimeType := mime.TypeByExtension(filepath.Ext(path))
if mimeType == "" {
mimeType = "text/plain"
w.Header().Set("Content-Type", mimeType)
if b, err := bundled.Asset(path); err == nil {
console.Debug("SendFile: http.ServeFile(%s)", filepath.Join(settings.UserRoot, path))
http.ServeFile(w, r, filepath.Join(settings.UserRoot, path))