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.
22 lines
370 B
22 lines
370 B
1 year ago
|
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)
|
||
|
}
|