瀏覽代碼

Simplifies c.File()

Manu Mtz-Almeida 10 年之前
父節點
當前提交
66251d1741
共有 3 個文件被更改,包括 1 次插入18 次删除
  1. 1 4
      context.go
  2. 0 13
      render/file.go
  3. 0 1
      render/render.go

+ 1 - 4
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{}) {

+ 0 - 13
render/file.go

@@ -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
-}

+ 0 - 1
render/render.go

@@ -18,7 +18,6 @@ var (
 	_ Render     = Redirect{}
 	_ Render     = Data{}
 	_ Render     = HTML{}
-	_ Render     = File{}
 	_ HTMLRender = HTMLDebug{}
 	_ HTMLRender = HTMLProduction{}
 )