Ejemplo n.º 1
0
func ApiRouter(statsMiddleware *stats.Stats) *mux.Router {
	router := mux.NewRouter()
	router.HandleFunc("/submit", SubmitHandler)
	router.HandleFunc("/stats", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "application/json")
		stats := statsMiddleware.Data()
		b, _ := json.Marshal(stats)
		w.Write(b)
	})

	return router
}
Ejemplo n.º 2
0
// AdminAionAPIServerStats returns Aion API server statistics
func AdminAionAPIServerStats(mw *stats.Stats) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "application/json")
		stats := mw.Data()

		b, err := json.Marshal(stats)
		if err != nil {
			log.Println(err)
		}

		w.Write(b)
	}
}