fresh

根据HTTP请求头与响应头判断是否未修改(304 Not Modified)。

Example

  1. package main
  2. import (
  3. "bytes"
  4. "github.com/vicanso/elton"
  5. "github.com/vicanso/elton/middleware"
  6. )
  7. func main() {
  8. e := elton.New()
  9. e.Use(middleware.NewDefaultFresh())
  10. e.Use(middleware.NewDefaultETag())
  11. e.GET("/", func(c *elton.Context) (err error) {
  12. c.BodyBuffer = bytes.NewBufferString("abcd")
  13. return
  14. })
  15. err := e.ListenAndServe(":3000")
  16. if err != nil {
  17. panic(err)
  18. }
  19. }