Exemple #1
0
func main() {
	app := noxu.CreateApp()

	router := &routing.Router{}

	router.Get(staticserver.ServeStatic("/static", "/public", staticserver.EXT_ALL))

	router.Get("/", controller.HTTPWrap(&controllers.HomeController{}, "Test"))

	router.Get("/login", controller.HTTPWrap(&controllers.LoginController{}, "Get"))
	router.Post("/login", controller.HTTPWrap(&controllers.LoginController{}, "Post"))

	app.Server.Handler = router

	app.Run()
}
Exemple #2
0
func TestHTTPWrap(t *testing.T) {
	wrapped := controller.HTTPWrap(&TestController{}, "Test")

	w := httptest.NewRecorder()
	r, _ := http.NewRequest("GET", "/", nil)

	wrapped(w, r)

	body, _ := ioutil.ReadAll(w.Body)

	assert.Equal(t, []byte("text"), body)
}