Пример #1
0
func runServer(cnf *config.Config, db *gorm.DB) {
	// Initialise the oauth service
	oauthService := oauth.NewService(cnf, db)

	// Initialise the accounts service
	_ = accounts.NewService(cnf, db, oauthService)

	// Initialise the web service
	_ = web.NewService(cnf, oauthService)

	// Start a classic negroni app
	webApp := negroni.Classic()

	// Create a router instance
	router := mux.NewRouter().StrictSlash(true)

	// Add routes for the oauth package (REST tokens endpoint)
	routes.AddRoutes(oauth.Routes, router.PathPrefix("/api/v1/oauth").Subrouter())

	// Add routes for the web package (register, login authorize web pages)
	routes.AddRoutes(web.Routes, router.PathPrefix("/web").Subrouter())

	// Set the router
	webApp.UseHandler(router)

	// Run the server on port 8080
	webApp.Run(":8080")
}
Пример #2
0
// RegisterRoutes registers route handlers for the web package
func RegisterRoutes(router *mux.Router, service *Service) {
	subRouter := router.PathPrefix("/web").Subrouter()
	routes.AddRoutes(newRoutes(service), subRouter)
}
Пример #3
0
// RegisterRoutes registers route handlers for the health service
func RegisterRoutes(router *mux.Router, service *Service) {
	routes.AddRoutes(newRoutes(service), router)
}