|
@@ -2,8 +2,12 @@ package srv
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "io"
|
|
|
"net/http"
|
|
|
+ "os"
|
|
|
"time"
|
|
|
+
|
|
|
+ "git.clearsky.net.au/cody/gex.git/utils"
|
|
|
)
|
|
|
|
|
|
type Res struct {
|
|
@@ -30,6 +34,22 @@ func (res *Res) Send(txt string) {
|
|
|
fmt.Fprint(res.w, txt)
|
|
|
}
|
|
|
|
|
|
+func (res *Res) File(filePath string) error {
|
|
|
+ file, err := os.Open(filePath)
|
|
|
+ if err != nil {
|
|
|
+ utils.Err(err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ defer file.Close()
|
|
|
+
|
|
|
+ _, err = io.Copy(res.w, file)
|
|
|
+ if err != nil {
|
|
|
+ utils.Err(err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func (res *Res) Redirect(url string) {
|
|
|
for _, v := range res.cookies {
|
|
|
http.SetCookie(res.w, v)
|