コード例 #1
0
ファイル: setup.go プロジェクト: dejanstrbac/gohackernews
// Setup sets up our application
func Setup(server *server.Server) {

	// Setup log
	server.Logger = log.New(server.Config("log"), server.Production())

	// Set up our assets
	setupAssets(server)

	// Setup our view templates
	setupView(server)

	// Setup our database
	setupDatabase(server)

	// Routing
	router, err := router.New(server.Logger, server)
	if err != nil {
		server.Fatalf("Error creating router %s", err)
	}

	// Setup our authentication and authorisation
	authorise.Setup(server)

	// Add a prefilter to store the current user on the context, so that we only fetch it once
	// We use this below in Resource, and also in views to determine current user attributes
	router.AddFilter(authorise.CurrentUserFilter)

	// Add an authenticity token filter to write out a secret token for each request (CSRF protection)
	router.AddFilter(authorise.AuthenticityTokenFilter)

	// Setup our router and handlers
	setupRoutes(router)

}
コード例 #2
0
ファイル: setup.go プロジェクト: rohanthewiz/fragmenta-app
// Setup sets up our application
func Setup(server *server.Server) {

	// Setup log
	server.Logger = log.New(server.Config("log"), server.Production())

	// Set up our assets
	setupAssets(server)

	// Setup our view templates
	setupView(server)

	// Setup our database
	setupDatabase(server)

	// Routing
	router, err := router.New(server.Logger, server)
	if err != nil {
		server.Fatalf("Error creating router %s", err)
	}

	// Setup our router and handlers
	setupRoutes(router)

}