context.go
func (ctx *Context) ServeFileContent(file string, names ...string) {
	var name string
	if len(names) > 0 {
		name = names[0]
	} else {
		name = path.Base(file)
	}

	f, err := os.Open(file)
	if err != nil {
		if Env == PROD {
			http.Error(ctx.Resp, "Internal Server Error", 500)
		} else {
			http.Error(ctx.Resp, err.Error(), 500)
		}
		return
	}
	defer f.Close()

	ctx.setRawContentHeader()
	http.ServeContent(ctx.Resp, ctx.Req.Request, name, time.Now(), f)
}
func (ctx *Context) ServeFileContent(file string, names ...string) {
	var name string
	if len(names) > 0 {
		name = names[0]
	} else {
		name = path.Base(file)
	}

	f, err := os.Open(file)
	if err != nil {
		if Env == PROD {
			http.Error(ctx.Resp, "Internal Server Error", 500)
		} else {
			http.Error(ctx.Resp, err.Error(), 500)
		}
		return
	}
	defer f.Close()

	ctx.setRawContentHeader()
	http.ServeContent(ctx.Resp, ctx.Req.Request, name, time.Now(), f)
}
func ( ctx * Context ) ServeFileContent ( file string , names ... string ) { var name string if len ( names ) > 0 { name = names [ 0 ] } else { name = path . Base ( file ) } f , err := os . Open ( file ) if err != nil { if Env == PROD { http . Error ( ctx . Resp , " " , 500 ) } else { http . Error ( ctx . Resp , err . Error ( ) , 500 ) } return } defer f . Close ( ) ctx . setRawContentHeader ( ) http . ServeContent ( ctx . Resp , ctx . Req . Request , name , time . Now ( ) , f ) }
// ServeFileContent serves given file as content to response.
ServeFileContent serves given file as content to response .