Esempio n. 1
0
func launchBackend(backend string, addr string) *httptest.ResponseRecorder {
	router := router.NewRouter()
	recorder := httptest.NewRecorder()

	router.Get("/", http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
		fmt.Fprintf(recorder, "%s", backend)
	}))

	server := &http.Server{Addr: addr, Handler: router}
	go server.ListenAndServe()

	return recorder
}
Esempio n. 2
0
func main() {
	router := router.NewRouter()
	router.Get("/", http.HandlerFunc(root))
	router.Get("/entries/:id", http.HandlerFunc(entry))
	http.ListenAndServe(":3000", router)
}