Example #1
0
// Test daryl/zeus ns/op
func BenchmarkZeusMux(b *testing.B) {
	request, _ := http.NewRequest("GET", "/sd/test", nil)
	response := httptest.NewRecorder()
	muxx := zeus.New()

	muxx.GET("/", Bench)
	muxx.GET("/a", Bench)
	muxx.GET("/aas", Bench)
	muxx.GET("/sd/:id", Bench)

	for n := 0; n < b.N; n++ {
		muxx.ServeHTTP(response, request)
	}
}
func loadZeusSingle(method, path string, handler http.HandlerFunc) http.Handler {
	m := zeus.New()
	switch method {
	case "GET":
		m.GET(path, handler)
	case "POST":
		m.POST(path, handler)
	case "PUT":
		m.PUT(path, handler)
	case "DELETE":
		m.DELETE(path, handler)
	default:
		panic("Unknow HTTP method: " + method)
	}
	return m
}
Example #3
0
func init() {
	/*
	*
	* Define routes here!
	*
	 */
	router := zeus.New()

	router.GET("/", Index)
	router.POST("/create-event", createEvent)

	/*
	*
	* Listen on port 1111!
	*
	 */
	router.Listen(":1111")
}
// Zeus
func loadZeus(routes []route) http.Handler {
	m := zeus.New()
	for _, route := range routes {
		switch route.method {
		case "GET":
			m.GET(route.path, http.HandlerFunc(httpHandlerFunc))
		case "POST":
			m.POST(route.path, http.HandlerFunc(httpHandlerFunc))
		case "PUT":
			m.PUT(route.path, http.HandlerFunc(httpHandlerFunc))
		case "DELETE":
			m.DELETE(route.path, http.HandlerFunc(httpHandlerFunc))
		default:
			panic("Unknow HTTP method: " + route.method)
		}
	}
	return m
}