fresh
根据HTTP请求头与响应头判断是否未修改(304 Not Modified)。
Example
package main
import (
"bytes"
"github.com/vicanso/elton"
"github.com/vicanso/elton/middleware"
)
func main() {
e := elton.New()
e.Use(middleware.NewDefaultFresh())
e.Use(middleware.NewDefaultETag())
e.GET("/", func(c *elton.Context) (err error) {
c.BodyBuffer = bytes.NewBufferString("abcd")
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}