Beispiel #1
0
func init() {
	mux.HandleFunc("/api-docs", weft.MakeHandlerPage(docHandler))
	mux.HandleFunc("/app", weft.MakeHandlerAPI(appHandler))
	mux.HandleFunc("/app/metric", weft.MakeHandlerAPI(appmetricHandler))
	mux.HandleFunc("/application/counter", weft.MakeHandlerAPI(applicationcounterHandler))
	mux.HandleFunc("/application/metric", weft.MakeHandlerAPI(applicationmetricHandler))
	mux.HandleFunc("/application/timer", weft.MakeHandlerAPI(applicationtimerHandler))
	mux.HandleFunc("/data/completeness", weft.MakeHandlerAPI(datacompletenessHandler))
	mux.HandleFunc("/data/completeness/summary", weft.MakeHandlerAPI(datacompletenesssummaryHandler))
	mux.HandleFunc("/data/completeness/tag", weft.MakeHandlerAPI(datacompletenesstagHandler))
	mux.HandleFunc("/data/completeness/type", weft.MakeHandlerAPI(datacompletenesstypeHandler))
	mux.HandleFunc("/data/latency", weft.MakeHandlerAPI(datalatencyHandler))
	mux.HandleFunc("/data/latency/summary", weft.MakeHandlerAPI(datalatencysummaryHandler))
	mux.HandleFunc("/data/latency/tag", weft.MakeHandlerAPI(datalatencytagHandler))
	mux.HandleFunc("/data/latency/threshold", weft.MakeHandlerAPI(datalatencythresholdHandler))
	mux.HandleFunc("/data/site", weft.MakeHandlerAPI(datasiteHandler))
	mux.HandleFunc("/data/type", weft.MakeHandlerAPI(datatypeHandler))
	mux.HandleFunc("/field/device", weft.MakeHandlerAPI(fielddeviceHandler))
	mux.HandleFunc("/field/metric", weft.MakeHandlerAPI(fieldmetricHandler))
	mux.HandleFunc("/field/metric/summary", weft.MakeHandlerAPI(fieldmetricsummaryHandler))
	mux.HandleFunc("/field/metric/tag", weft.MakeHandlerAPI(fieldmetrictagHandler))
	mux.HandleFunc("/field/metric/threshold", weft.MakeHandlerAPI(fieldmetricthresholdHandler))
	mux.HandleFunc("/field/model", weft.MakeHandlerAPI(fieldmodelHandler))
	mux.HandleFunc("/field/state", weft.MakeHandlerAPI(fieldstateHandler))
	mux.HandleFunc("/field/state/tag", weft.MakeHandlerAPI(fieldstatetagHandler))
	mux.HandleFunc("/field/type", weft.MakeHandlerAPI(fieldtypeHandler))
	mux.HandleFunc("/tag", weft.MakeHandlerAPI(tagHandler))
	mux.HandleFunc("/tag/", weft.MakeHandlerAPI(tagsHandler))
}
Beispiel #2
0
func init() {
	muxV1GeoJSON = http.NewServeMux()
	muxV1GeoJSON.HandleFunc("/quake", weft.MakeHandlerAPI(quakesRegionV1))
	muxV1GeoJSON.HandleFunc("/quake/", weft.MakeHandlerAPI(quakeV1))
	muxV1GeoJSON.HandleFunc("/intensity", weft.MakeHandlerAPI(intensityMeasuredLatestV1))
	muxV1GeoJSON.HandleFunc("/felt/report", weft.MakeHandlerAPI(feltV1))

	muxV1JSON = http.NewServeMux()
	muxV1JSON.HandleFunc("/news/geonet", weft.MakeHandlerAPI(newsV1))

	muxV2GeoJSON = http.NewServeMux()
	muxV2GeoJSON.HandleFunc("/intensity", weft.MakeHandlerAPI(intensityV2))
	muxV2GeoJSON.HandleFunc("/quake", weft.MakeHandlerAPI(quakesV2))
	muxV2GeoJSON.HandleFunc("/quake/", weft.MakeHandlerAPI(quakeV2))
	muxV2GeoJSON.HandleFunc("/quake/history/", weft.MakeHandlerAPI(quakeHistoryV2))
	muxV2GeoJSON.HandleFunc("/volcano/val", weft.MakeHandlerAPI(valV2))

	muxV2JSON = http.NewServeMux()
	muxV2JSON.HandleFunc("/news/geonet", weft.MakeHandlerAPI(newsV2))
	muxV2JSON.HandleFunc("/quake/stats", weft.MakeHandlerAPI(quakeStatsV2))

	// protobufs
	muxProto = http.NewServeMux()
	muxProto.HandleFunc("/quake", weft.MakeHandlerAPI(quakesProto))
	muxProto.HandleFunc("/quake/", weft.MakeHandlerAPI(quakeProto))
	muxProto.HandleFunc("/quake/technical/", weft.MakeHandlerAPI(quakeTechnicalProto))
	muxProto.HandleFunc("/quake/history/", weft.MakeHandlerAPI(quakeHistoryProto))
	muxProto.HandleFunc("/intensity", weft.MakeHandlerAPI(intensityProto))
	muxProto.HandleFunc("/volcano/val", weft.MakeHandlerAPI(valProto))
	muxProto.HandleFunc("/news/geonet", weft.MakeHandlerAPI(newsProto))
	muxProto.HandleFunc("/quake/stats", weft.MakeHandlerAPI(quakeStatsProto))

	// muxDefault handles routes with no Accept version.
	// soh routes
	muxDefault = http.NewServeMux()
	muxDefault.HandleFunc("/soh", http.HandlerFunc(soh))
	muxDefault.HandleFunc("/soh/esb", http.HandlerFunc(sohEsb))
	muxDefault.HandleFunc("/soh/up", http.HandlerFunc(up))
	muxDefault.HandleFunc("/soh/impact", http.HandlerFunc(impactSOH))

	muxDefault.HandleFunc("/cap/1.2/GPA1.0/quake/", weft.MakeHandlerAPI(capQuake))
	muxDefault.HandleFunc("/cap/1.2/GPA1.0/feed/atom1.0/quake", weft.MakeHandlerAPI(capQuakeFeed))
	// The 'latest' version of the API for unversioned requests.
	muxDefault.HandleFunc("/quake/", weft.MakeHandlerAPI(quakeV2))
	muxDefault.HandleFunc("/quake", weft.MakeHandlerAPI(quakesV2))
	muxDefault.HandleFunc("/quake/history/", weft.MakeHandlerAPI(quakeHistoryV2))
	muxDefault.HandleFunc("/quake/stats", weft.MakeHandlerAPI(quakeStatsV2))
	muxDefault.HandleFunc("/intensity", weft.MakeHandlerAPI(intensityV2))
	muxDefault.HandleFunc("/news/geonet", weft.MakeHandlerAPI(newsV2))
	muxDefault.HandleFunc("/volcano/val", weft.MakeHandlerAPI(valV2))
	muxDefault.HandleFunc("/quakes/services/all.json", weft.MakeHandlerAPI(quakesWWWall))
	muxDefault.HandleFunc("/quakes/services/felt.json", weft.MakeHandlerAPI(quakesWWWfelt))
	muxDefault.HandleFunc("/quakes/services/quakes/newzealand/", weft.MakeHandlerAPI(quakesWWWnz))
	muxDefault.HandleFunc("/quake/services/quake/", weft.MakeHandlerAPI(quakeWWW))

	for _, v := range []*http.ServeMux{muxV1JSON, muxV2JSON, muxV1GeoJSON, muxV2GeoJSON, muxDefault, muxProto} {
		v.HandleFunc("/", weft.MakeHandlerPage(docs))
	}

}
Beispiel #3
0
func init() {
	mux.HandleFunc("/", weft.MakeHandlerPage(home))
	mux.HandleFunc("/health", health)

	// routes for balancers and probes.
	mux.HandleFunc("/soh/up", http.HandlerFunc(up))
	mux.HandleFunc("/soh", http.HandlerFunc(soh))

}
Beispiel #4
0
func init() {
	indexTemp = template.Must(template.ParseFiles("assets/tmpl/index.html"))
	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))

	serveMux = http.NewServeMux()
	serveMux.HandleFunc("/geojson", weft.MakeHandlerAPI(getQuakesGeoJson))
	serveMux.HandleFunc("/count", weft.MakeHandlerAPI(getQuakesCount))
	serveMux.HandleFunc("/csv", weft.MakeHandlerAPI(getQuakesCsv))
	serveMux.HandleFunc("/gml", weft.MakeHandlerAPI(getQuakesGml))
	serveMux.HandleFunc("/kml", weft.MakeHandlerAPI(getQuakesKml))
	serveMux.HandleFunc("/", weft.MakeHandlerPage(indexPage))

	// routes for balancers and probes.
	serveMux.HandleFunc("/soh/up", http.HandlerFunc(up))
	serveMux.HandleFunc("/soh", http.HandlerFunc(soh))
}
Beispiel #5
0
func init() {
	indexTemp = template.Must(template.ParseFiles("assets/tmpl/index.html"))
	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))

	/**
	  Request example:
	  1. ows
	   http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1
	    &outputFormat=json&cql_filter=origintime>='2013-06-01'+AND+origintime<'2014-01-01'+AND+usedphasecount>60

	  2. wms
	   http://wfs.geonet.org.nz/geonet/wms/kml?layers=geonet:quake_search_v1&maxFeatures=50
	*/
	serveMux = http.NewServeMux()
	serveMux.HandleFunc("/geonet/wms/kml", weft.MakeHandlerAPI(getQuakesKml))
	serveMux.HandleFunc("/geonet/ows", weft.MakeHandlerAPI(getQuakesWfs))
	serveMux.HandleFunc("/", weft.MakeHandlerPage(indexPage))

	// routes for balancers and probes.
	serveMux.HandleFunc("/soh/up", http.HandlerFunc(up))
	serveMux.HandleFunc("/soh", http.HandlerFunc(soh))
}
Beispiel #6
0
func init() {
	var err error
	webServerPort = os.Getenv("MTR_UI_PORT")
	mtrApiUrlString := os.Getenv("MTR_API_URL")
	switch "" {
	case webServerPort:
		log.Fatal("error, environment variable MTR_UI_PORT must be set (eg: 8080)")
	case mtrApiUrlString:
		log.Fatal("error, environment variable MTR_API_URL must be set (eg: https://mtr-api.geonet.org.nz)")
	}

	if mtrApiUrl, err = url.Parse(mtrApiUrlString); err != nil {
		log.Fatal(err)
	}

	// Add a proxy handler for CSV & GeoJSON from mtr-api.geonet.org.nz
	// proxies requests like ./p/data/latency?siteID=GISB&typeID=latency.gnss.1hz
	// with Accept="text/csv".  Avoids cross origin errors.
	apiDirector := func(r *http.Request) {
		r.Host = mtrApiUrl.Host
		r.URL.Scheme = mtrApiUrl.Scheme
		r.URL.Host = mtrApiUrl.Host
	}

	mux = http.NewServeMux()
	mux.Handle("/p/", http.StripPrefix("/p", &httputil.ReverseProxy{Director: apiDirector}))
	mux.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("assets/js"))))

	mux.HandleFunc("/", weft.MakeHandlerPage(homePageHandler))
	mux.HandleFunc("/field", weft.MakeHandlerPage(fieldPageHandler))
	mux.HandleFunc("/field/", weft.MakeHandlerPage(fieldPageHandler))
	mux.HandleFunc("/field/metric", weft.MakeHandlerPage(metricDetailHandler))
	mux.HandleFunc("/field/metrics", weft.MakeHandlerPage(fieldMetricsPageHandler))
	mux.HandleFunc("/field/devices", weft.MakeHandlerPage(fieldDevicesPageHandler))
	mux.HandleFunc("/field/plot", weft.MakeHandlerPage(fieldPlotPageHandler))
	mux.HandleFunc("/data", weft.MakeHandlerPage(dataPageHandler))
	mux.HandleFunc("/data/", weft.MakeHandlerPage(dataPageHandler))
	mux.HandleFunc("/data/sites", weft.MakeHandlerPage(dataSitesPageHandler))
	mux.HandleFunc("/data/metrics", weft.MakeHandlerPage(dataMetricsPageHandler))
	mux.HandleFunc("/data/plot", weft.MakeHandlerPage(dataPlotPageHandler))
	mux.HandleFunc("/data/completeness/plot", weft.MakeHandlerPage(dataCompletenessPlotPageHandler))
	mux.HandleFunc("/map", weft.MakeHandlerPage(mapPageHandler))
	mux.HandleFunc("/map/", weft.MakeHandlerPage(mapPageHandler))
	mux.HandleFunc("/map1", weft.MakeHandlerPage(mapPageHandler))
	mux.HandleFunc("/map1/", weft.MakeHandlerPage(mapPageHandler))
	mux.HandleFunc("/interactive_map", weft.MakeHandlerPage(interactiveMapPageHandler))
	mux.HandleFunc("/interactive_map/", weft.MakeHandlerPage(interactiveMapPageHandler))
	mux.HandleFunc("/search", weft.MakeHandlerPage(searchPageHandler))
	mux.HandleFunc("/tag", weft.MakeHandlerPage(tagPageHandler))
	mux.HandleFunc("/tag/", weft.MakeHandlerPage(tagPageHandler))
	mux.HandleFunc("/app", weft.MakeHandlerPage(appPageHandler))
	mux.HandleFunc("/app/", weft.MakeHandlerPage(appPageHandler))
	mux.HandleFunc("/app/plot", weft.MakeHandlerPage(appPlotPageHandler))

	// routes for balancers and probes.
	mux.HandleFunc("/soh/up", http.HandlerFunc(up))
	mux.HandleFunc("/soh", http.HandlerFunc(soh))
}
Beispiel #7
0
func init() {
	mux.HandleFunc("/api-docs", weft.MakeHandlerPage(docHandler))
	mux.HandleFunc("/csv/1.0.0/", weft.MakeHandlerAPI(csv1_0_0sHandler))
	mux.HandleFunc("/quakeml/1.2/", weft.MakeHandlerAPI(quakeml1_2sHandler))
	mux.HandleFunc("/quakeml-rt/1.2/", weft.MakeHandlerAPI(quakeml_rt1_2sHandler))
}