예제 #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
}
예제 #2
0
파일: server.go 프로젝트: r7kamura/router
func main() {
	router := router.NewRouter()
	router.Get("/", http.HandlerFunc(root))
	router.Get("/entries/:id", http.HandlerFunc(entry))
	http.ListenAndServe(":3000", router)
}
예제 #3
0
func init() {
	sugoiCalendarHandler = router.NewRouter()
	sugoiCalendarHandler.Get("/titles", TitleIndexHandler)
	sugoiCalendarHandler.Get("/titles/:id", TitleShowHandler)
	sugoiCalendarHandler.Post("/titles", TitleCreateHandler)
}