From 66251d17413230ced56f6121c22d6361630e236f Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Thu, 21 May 2015 15:49:10 +0200 Subject: [PATCH] Simplifies c.File() --- context.go | 5 +---- render/file.go | 13 ------------- render/render.go | 1 - 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 render/file.go diff --git a/context.go b/context.go index 164b6457..ba493ad8 100644 --- a/context.go +++ b/context.go @@ -375,10 +375,7 @@ func (c *Context) Data(code int, contentType string, data []byte) { // Writes the specified file into the body stream func (c *Context) File(filepath string) { - c.Render(-1, render.File{ - Path: filepath, - Request: c.Request, - }) + http.ServeFile(c.Writer, c.Request, filepath) } func (c *Context) SSEvent(name string, message interface{}) { diff --git a/render/file.go b/render/file.go deleted file mode 100644 index dd7c8ece..00000000 --- a/render/file.go +++ /dev/null @@ -1,13 +0,0 @@ -package render - -import "net/http" - -type File struct { - Path string - Request *http.Request -} - -func (r File) Write(w http.ResponseWriter) error { - http.ServeFile(w, r.Request, r.Path) - return nil -} diff --git a/render/render.go b/render/render.go index 57a57249..1bcae933 100644 --- a/render/render.go +++ b/render/render.go @@ -18,7 +18,6 @@ var ( _ Render = Redirect{} _ Render = Data{} _ Render = HTML{} - _ Render = File{} _ HTMLRender = HTMLDebug{} _ HTMLRender = HTMLProduction{} )