コード例 #1
0
ファイル: Router.go プロジェクト: livenson/fox
func NewRouter() *mux.Router {
	router := mux.NewRouter().StrictSlash(true)
	for _, route := range routes {
		var handler http.Handler

		handler = route.HandlerFunc
		handler = util.NewTelemetry(handler, route.Name)

		handler = util.LoggingHandler(handler, log)

		router.
			Methods(route.Method).
			Path(route.Pattern).
			Name(route.Name).
			Handler(handlers.LoggingHandler(os.Stdout, handler))
		log.Debug("Added " + route.String())

	}
	return router
}
コード例 #2
0
ファイル: Router.go プロジェクト: livenson/fox
func NewRouter() *mux.Router {
	router := mux.NewRouter().StrictSlash(true)
	for _, route := range routes {
		var handler http.Handler

		authz.GetProvider().AddRestriction(route.Role, route.Method, route.Pattern)

		handler = route.HandlerFunc
		handler = util.NewTelemetry(handler, route.Name)

		handler = util.LoggingHandler(handler, log)
		handler = authz.PermissionHandler(handler)
		router.
			Methods(route.Method).
			Path(route.Pattern).
			Name(route.Name).
			Handler(handler)
		log.Debugf("Added route %s", route.String())
	}
	return router
}