Simplifies c.File()
This commit is contained in:
		@ -375,10 +375,7 @@ func (c *Context) Data(code int, contentType string, data []byte) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Writes the specified file into the body stream
 | 
					// Writes the specified file into the body stream
 | 
				
			||||||
func (c *Context) File(filepath string) {
 | 
					func (c *Context) File(filepath string) {
 | 
				
			||||||
	c.Render(-1, render.File{
 | 
						http.ServeFile(c.Writer, c.Request, filepath)
 | 
				
			||||||
		Path:    filepath,
 | 
					 | 
				
			||||||
		Request: c.Request,
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Context) SSEvent(name string, message interface{}) {
 | 
					func (c *Context) SSEvent(name string, message interface{}) {
 | 
				
			||||||
 | 
				
			|||||||
@ -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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -18,7 +18,6 @@ var (
 | 
				
			|||||||
	_ Render     = Redirect{}
 | 
						_ Render     = Redirect{}
 | 
				
			||||||
	_ Render     = Data{}
 | 
						_ Render     = Data{}
 | 
				
			||||||
	_ Render     = HTML{}
 | 
						_ Render     = HTML{}
 | 
				
			||||||
	_ Render     = File{}
 | 
					 | 
				
			||||||
	_ HTMLRender = HTMLDebug{}
 | 
						_ HTMLRender = HTMLDebug{}
 | 
				
			||||||
	_ HTMLRender = HTMLProduction{}
 | 
						_ HTMLRender = HTMLProduction{}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user