SetContentTypeByExt
通过文件(文件后缀)设置Content-Type。
Example
package main
import (
"github.com/vicanso/elton"
"github.com/vicanso/elton/middleware"
)
func main() {
e := elton.New()
e.Use(middleware.NewDefaultResponder())
e.GET("/", func(c *elton.Context) (err error) {
c.SetContentTypeByExt(".html")
c.Body = `<html>
<body>
<p>Hello, World!</p>
</body>
</html>`
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}