|
|
|
|
|
|
|
|
w.WriteHeader(http.StatusAccepted) |
|
|
w.WriteHeader(http.StatusAccepted) |
|
|
w.Header().Set("X-Auth-Server", "rex") |
|
|
w.Header().Set("X-Auth-Server", "rex") |
|
|
}, "POST") |
|
|
}, "POST") |
|
|
|
|
|
app.register("/signup", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
w.WriteHeader(http.StatusAccepted) |
|
|
|
|
|
w.Header().Set("X-Auth-Server", "rex") |
|
|
|
|
|
}), "POST") |
|
|
|
|
|
|
|
|
request, _ := http.NewRequest("POST", "/login", nil) |
|
|
request, _ := http.NewRequest("POST", "/login", nil) |
|
|
response := httptest.NewRecorder() |
|
|
response := httptest.NewRecorder() |
|
|
app.ServeHTTP(response, request) |
|
|
app.ServeHTTP(response, request) |
|
|
So(response.Code, ShouldEqual, http.StatusAccepted) |
|
|
So(response.Code, ShouldEqual, http.StatusAccepted) |
|
|
So(response.Header().Get("X-Auth-Server"), ShouldEqual, "rex") |
|
|
So(response.Header().Get("X-Auth-Server"), ShouldEqual, "rex") |
|
|
|
|
|
|
|
|
|
|
|
request, _ = http.NewRequest("POST", "/signup", nil) |
|
|
|
|
|
response = httptest.NewRecorder() |
|
|
|
|
|
app.ServeHTTP(response, request) |
|
|
|
|
|
So(response.Code, ShouldEqual, http.StatusAccepted) |
|
|
|
|
|
So(response.Header().Get("X-Auth-Server"), ShouldEqual, "rex") |
|
|
|
|
|
|
|
|
|
|
|
So(func() { |
|
|
|
|
|
app.register("/panic", nil) |
|
|
|
|
|
}, ShouldPanic) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app := New() |
|
|
app := New() |
|
|
app.GET("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
app.GET("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
w.Header().Set("X-Powered-By", "rex") |
|
|
w.Header().Set("X-Powered-By", "rex") |
|
|
w.Header().Set("Content-Type", "application/json") |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
Convey("rex.GET", t, func() { |
|
|
Convey("rex.GET", t, func() { |
|
|
|
|
|
|
|
|
app.ServeHTTP(response, request) |
|
|
app.ServeHTTP(response, request) |
|
|
|
|
|
|
|
|
So(response.Header().Get("X-Powered-By"), ShouldEqual, "rex") |
|
|
So(response.Header().Get("X-Powered-By"), ShouldEqual, "rex") |
|
|
So(response.Header().Get("Content-Type"), ShouldEqual, "application/json") |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestHEAD(t *testing.T) { |
|
|
|
|
|
app := New() |
|
|
|
|
|
app.HEAD("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
w.Header().Set("X-Powered-By", "rex") |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Convey("rex.HEAD", t, func() { |
|
|
|
|
|
request, _ := http.NewRequest("HEAD", "/", nil) |
|
|
|
|
|
response := httptest.NewRecorder() |
|
|
|
|
|
|
|
|
|
|
|
app.ServeHTTP(response, request) |
|
|
|
|
|
|
|
|
|
|
|
So(response.Header().Get("X-Powered-By"), ShouldEqual, "rex") |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestOPTIONS(t *testing.T) { |
|
|
|
|
|
app := New() |
|
|
|
|
|
app.OPTIONS("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
w.Header().Set("X-Powered-By", "rex") |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Convey("rex.OPTIONS", t, func() { |
|
|
|
|
|
request, _ := http.NewRequest("OPTIONS", "/", nil) |
|
|
|
|
|
response := httptest.NewRecorder() |
|
|
|
|
|
|
|
|
|
|
|
app.ServeHTTP(response, request) |
|
|
|
|
|
|
|
|
|
|
|
So(response.Header().Get("X-Powered-By"), ShouldEqual, "rex") |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|