@@ -317,7 +317,8 @@ func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interfa
317
317
http .ServeContent (ctx .Resp , ctx .Req , name , modtime , r )
318
318
}
319
319
320
- // PlainText render content as plain text
320
+ // PlainText render content as plain text, this will override basecontext's method
321
+ // because we need a beautiful failed page
321
322
func (ctx * Context ) PlainText (status int , bs []byte ) {
322
323
ctx .Resp .WriteHeader (status )
323
324
ctx .Resp .Header ().Set ("Content-Type" , "text/plain;charset=utf-8" )
@@ -326,24 +327,6 @@ func (ctx *Context) PlainText(status int, bs []byte) {
326
327
}
327
328
}
328
329
329
- // ServeFile serves given file to response.
330
- func (ctx * Context ) ServeFile (file string , names ... string ) {
331
- var name string
332
- if len (names ) > 0 {
333
- name = names [0 ]
334
- } else {
335
- name = path .Base (file )
336
- }
337
- ctx .Resp .Header ().Set ("Content-Description" , "File Transfer" )
338
- ctx .Resp .Header ().Set ("Content-Type" , "application/octet-stream" )
339
- ctx .Resp .Header ().Set ("Content-Disposition" , "attachment; filename=" + name )
340
- ctx .Resp .Header ().Set ("Content-Transfer-Encoding" , "binary" )
341
- ctx .Resp .Header ().Set ("Expires" , "0" )
342
- ctx .Resp .Header ().Set ("Cache-Control" , "must-revalidate" )
343
- ctx .Resp .Header ().Set ("Pragma" , "public" )
344
- http .ServeFile (ctx .Resp , ctx .Req , file )
345
- }
346
-
347
330
// ServeStream serves file via io stream
348
331
func (ctx * Context ) ServeStream (rd io.Reader , name string ) {
349
332
ctx .Resp .Header ().Set ("Content-Description" , "File Transfer" )
@@ -359,25 +342,6 @@ func (ctx *Context) ServeStream(rd io.Reader, name string) {
359
342
}
360
343
}
361
344
362
- // Error returned an error to web browser
363
- func (ctx * Context ) Error (status int , contents ... string ) {
364
- var v = http .StatusText (status )
365
- if len (contents ) > 0 {
366
- v = contents [0 ]
367
- }
368
- http .Error (ctx .Resp , v , status )
369
- }
370
-
371
- // Redirect redirect the request
372
- func (ctx * Context ) Redirect (location string , status ... int ) {
373
- code := http .StatusFound
374
- if len (status ) == 1 {
375
- code = status [0 ]
376
- }
377
-
378
- http .Redirect (ctx .Resp , ctx .Req , location , code )
379
- }
380
-
381
345
// SetCookie convenience function to set most cookies consistently
382
346
// CSRF and a few others are the exception here
383
347
func (ctx * Context ) SetCookie (name , value string , expiry int ) {
0 commit comments