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