1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-08 22:20:05 +00:00
cloudkeys-go/assets.go
Knut Ahlers 0ad1681ee0
Remove old assets, prepare adding Vue serving
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-11-04 14:32:00 +01:00

19 lines
374 B
Go

package main
import (
"mime"
"net/http"
"path"
"path/filepath"
)
func serveAssets(res http.ResponseWriter, r *http.Request) {
data, err := Asset(path.Join("dist", r.RequestURI[1:]))
if err != nil {
http.Error(res, "Not found", http.StatusNotFound)
return
}
res.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(r.RequestURI)))
res.Write(data)
}