您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930
  1. package middleware
  2. import (
  3. "io"
  4. "net/http"
  5. "net/http/httptest"
  6. "testing"
  7. "git.thevis.us/skepto/rex"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestCompress(t *testing.T) {
  11. app := rex.New()
  12. app.Use(Compress)
  13. app.Get("/", func(w http.ResponseWriter, r *http.Request) {
  14. io.WriteString(w, "app")
  15. })
  16. Convey("rex.middleware.Compress", t, func() {
  17. request, _ := http.NewRequest("GET", "/", nil)
  18. request.Header.Set("Accept-Encoding", "gzip")
  19. response := httptest.NewRecorder()
  20. app.ServeHTTP(response, request)
  21. So(response.Header().Get("Content-Encoding"), ShouldEqual, "gzip")
  22. })
  23. }