Ejemplo n.º 1
0
func (r PingdomService) Run() {
	r.GET("/status/pingdom", func(c *gin.Context) {
		n := time.Now()
		status := "OK"

		db := database.NewMongoDB()
		err := db.Ping()

		if err != nil {
			status = err.Error()
		}

		type Pingdom struct {
			XMLName      xml.Name `xml:"pingdom_http_custom_check"`
			Status       string   `xml:"status"`
			ResponseTime string   `xml:"response_time"`
		}

		latency := int(time.Since(n) / time.Millisecond)

		pingdom := &Pingdom{
			Status:       status,
			ResponseTime: strconv.Itoa(latency),
		}

		c.XML(200, pingdom)
	})

}
Ejemplo n.º 2
0
func main() {
	mongo := database.NewMongoDB()

	bot.StationBot{}.Run(mongo)
	bot.LineBot{}.Run(mongo)
	bot.StatusBot{}.Run(mongo)
}
Ejemplo n.º 3
0
Archivo: api.go Proyecto: zannet/api
func main() {
	r := gin.Default()
	r.Use(gin.Logger())
	r.Use(gin.Recovery())
	r.Use(middleware.CORS())
	// r.Use(middleware.Authentication())
	r.Use(middleware.Analytics())
	r.Use(middleware.StatusPageIO())

	if config.Env == "production" {
		r.Use(middleware.NewRelic())
		middleware.InitNewrelicAgent(config.NewRelicLicense, config.NewRelicAppName, true)
	}

	databaseDB := database.NewMongoDB()

	parliamentarians := service.ParliamentariansService{r}
	parties := service.PartiesService{r}
	states := service.StatesService{r}
	pingdom := service.PingdomService{r}
	doc := service.ApiDocumentationService{r}

	parliamentarians.Run(databaseDB)
	parties.Run(databaseDB)
	states.Run(databaseDB)
	pingdom.Run()
	doc.Run()

	r.OPTIONS("/*path", func(c *gin.Context) {
		c.Writer.Header().Set("Allow", "GET, OPTIONS")
		c.Abort(200)
	})

	r.GET("/", func(c *gin.Context) {
		http.Redirect(
			c.Writer,
			c.Request,
			"http://databr.io",
			302)
	})

	log.Println("Listening port", config.Port)
	r.Run(":" + config.Port)
}
Ejemplo n.º 4
0
func main() {
	mongo := database.NewMongoDB()

	parser.Log.Debug("Running bot.SaveDeputiesFromTransparenciaBrasil{}")
	bot.SaveDeputiesFromTransparenciaBrasil{}.Run(mongo)

	parser.Log.Debug("Running bot.SaveDeputiesFromSearch{}")
	bot.SaveDeputiesFromSearch{}.Run(mongo)

	parser.Log.Debug("Running bot.SaveDeputiesFromXML{}")
	bot.SaveDeputiesFromXML{}.Run(mongo)

	parser.Log.Debug("Running bot.SaveDeputiesAbout{}")
	bot.SaveDeputiesAbout{}.Run(mongo)

	parser.Log.Debug("Running bot.SavePartiesFromTSE{}")
	bot.SavePartiesFromTSE{}.Run(mongo)

	//	bot.SaveDeputiesQuotas{}.Run(mongo)

	parser.Log.Debug("Running bot.SaveSenatorsFromIndex{}")
	bot.SaveSenatorsFromIndex{}.Run(mongo)
}
Ejemplo n.º 5
0
Convert JSON data into a map.
*/
func mapFromJSON(data []byte) map[string]interface{} {
	var result interface{}
	json.Unmarshal(data, &result)
	return result.(map[string]interface{})
}

var _ = Describe("Service", func() {
	var databaseDB database.MongoDB
	var request *http.Request
	var recorder *httptest.ResponseRecorder
	var r *gin.Engine

	BeforeEach(func() {
		databaseDB = database.NewMongoDB("test")
		r = gin.Default()

		parliamentarians := service.ParliamentariansService{r}
		parliamentarians.Run(databaseDB)

		parties := service.PartiesService{r}
		parties.Run(databaseDB)

		states := service.StatesService{r}
		states.Run(databaseDB)

		pingdom := service.PingdomService{r}
		pingdom.Run()

		doc := service.ApiDocumentationService{r}
Ejemplo n.º 6
0
func main() {
	mongo := database.NewMongoDB()

	bot.BasicStateBot{}.Run(mongo)
	bot.BasicCityBot{}.Run(mongo)
}
Ejemplo n.º 7
0
func main() {
	mongo := database.NewMongoDB()

	bot.SabespBot{}.Run(mongo)
}