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.
 
 
nucleus/internal/controller.go

21 lines
370 B

package internal
import (
"log"
"net/http"
"os"
)
type Controller struct{}
func (c *Controller) Render(w http.ResponseWriter, r *http.Request, t string) {
file, err := os.Open(t)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), 500)
return
}
defer file.Close()
fi, _ := file.Stat()
http.ServeContent(w, r, file.Name(), fi.ModTime(), file)
}