Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

header_test.go 649B

12345678910111213141516171819202122232425262728293031
  1. package middleware
  2. import (
  3. "io"
  4. "net/http"
  5. "net/http/httptest"
  6. "testing"
  7. "github.com/goanywhere/rex"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestHeader(t *testing.T) {
  11. var values = make(map[string]string)
  12. values["X-Powered-By"] = "rex server"
  13. app := rex.New()
  14. app.Use(Header(values))
  15. app.GET("/", func(w http.ResponseWriter, r *http.Request) {
  16. io.WriteString(w, "app")
  17. })
  18. Convey("rex.middleware.Header", t, func() {
  19. request, _ := http.NewRequest("GET", "/", nil)
  20. response := httptest.NewRecorder()
  21. app.ServeHTTP(response, request)
  22. So(response.Header().Get("X-Powered-By"), ShouldEqual, "rex server")
  23. })
  24. }