Esempio n. 1
0
File: mux.go Progetto: gorward/mux
// HANDLER create route using GorwardRouter values
func (r GowardRouter) Handler(handler http.Handler) Router {
	var route *mux.Route

	if r.FMiddleware != nil {
		handler = bindMiddlewares(handler, r.FMiddleware...)
	}

	if r.FPath == "/" && r.FParentRouter != nil {
		route = r.FParentRouter.NewRoute()
		route = route.Path(r.FPrefix)
	} else {
		route = r.FRouter.NewRoute()
		route.Path(r.FPath)
	}
	if r.FHost != "" {
		route = route.Host(r.FHost)
	}
	if r.Methods != nil {
		route = route.Methods(r.FMethods...)
	}

	route.Handler(handler)

	return r
}
Esempio n. 2
0
func (_ gitHandler) Route(r *mux.Route) {
	r.Path("/").Methods("POST").Headers(
		"Content-Type", "application/json",
		"X-GITHUB-EVENT", "",
	)
}