Beispiel #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
}
Beispiel #2
0
func main() {
	router := router.NewRouter()
	router.Get("/", http.HandlerFunc(root))
	router.Get("/entries/:id", http.HandlerFunc(entry))
	http.ListenAndServe(":3000", router)
}
Beispiel #3
0
func init() {
	sugoiCalendarHandler = router.NewRouter()
	sugoiCalendarHandler.Get("/titles", TitleIndexHandler)
	sugoiCalendarHandler.Get("/titles/:id", TitleShowHandler)
	sugoiCalendarHandler.Post("/titles", TitleCreateHandler)
}