mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-09 22:50:05 +00:00
19 lines
347 B
Go
19 lines
347 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"mime"
|
||
|
"net/http"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
func serveAssets(res http.ResponseWriter, r *http.Request) {
|
||
|
data, err := Asset(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)
|
||
|
}
|