|
4 | 4 | "bytes"
|
5 | 5 | "encoding/json"
|
6 | 6 | "io"
|
| 7 | + "io/ioutil" |
7 | 8 | "net/http"
|
8 | 9 | "net/url"
|
9 | 10 | "runtime"
|
@@ -244,7 +245,24 @@ func (flow *Flow) Redirect(newUrl string, status int) {
|
244 | 245 | http.Redirect(flow.respWrt, flow.req, newUrl, status)
|
245 | 246 | return
|
246 | 247 | }
|
247 |
| - flow.ErrorHTML(http.StatusInternalServerError, "Invalid Redirect", nil) |
| 248 | + flow.ErrorText(http.StatusInternalServerError, "Invalid Redirect", nil) |
| 249 | +} |
| 250 | + |
| 251 | +func (flow *Flow) StaticFile(status int, filepath string, mime string) { |
| 252 | + file, err := ioutil.ReadFile(filepath) |
| 253 | + if err != nil { |
| 254 | + flow.ErrorText(500, "Failed to load %s", err) |
| 255 | + return |
| 256 | + } |
| 257 | + flow.respWrt.Header().Add("content-type", mime) |
| 258 | + err = flow.Renderer.Data(flow.respWrt, status, file) |
| 259 | + flow.catchAfterErr(err) |
| 260 | +} |
| 261 | + |
| 262 | +func (flow *Flow) Data(status int, bytes []byte, mime string) { |
| 263 | + flow.respWrt.Header().Add("content-type", mime) |
| 264 | + err := flow.Renderer.Data(flow.respWrt, status, bytes) |
| 265 | + flow.catchAfterErr(err) |
248 | 266 | }
|
249 | 267 |
|
250 | 268 | func (flow *Flow) File(bytes []byte, filename string, mime string) {
|
|
0 commit comments