Exemplo n.º 1
0
func Main() {
	config = LoadConfig()
	BaseUrl = config.BaseUrl
	ArticlePrefix = config.ArticlePrefix

	log.LogTo(config.LogTo, config.LogLevel)
	logger = log.NewPrefixLogger("MAIN")

	db = newDb()
	defer db.Close()

	artclesPath := fmt.Sprintf("/%s", ArticlePrefix)
	articlePath := fmt.Sprintf("/%s/{source_slug}/{article_slug}/{article_id:[0-9]+}", ArticlePrefix)

	r := mux.NewRouter()
	r.HandleFunc(articlePath, serve(articleHandler)).Methods("GET")
	r.HandleFunc(articlePath, serve(reFetchArticleHandler)).Methods("PUT")
	r.HandleFunc(artclesPath, serve(articlesHandler)).Methods("GET")
	r.NotFoundHandler = http.HandlerFunc(unknownHandler)

	port := "8080" //os.Getenv("PORT")

	logger.Info("Listening on port %s\n", port)
	http.ListenAndServe(":"+port, r)
}
Exemplo n.º 2
0
func Main() {
	config = LoadConfig()
	BaseUrl = config.BaseUrl
	ArticlePrefix = config.ArticlePrefix

	log.LogTo(config.LogTo, config.LogLevel)
	logger = log.NewPrefixLogger("MAIN")

	db = newDb()
	defer db.Close()

	startCron()
	wait()
}