Documentation ¶
Index ¶
- func ShowUI(rw http.ResponseWriter, req *http.Request)
- type AlertItem
- type AlertReport
- type AlertRequest
- type CalendarItem
- type CalendarRequest
- type CalendarResponse
- type CalendarView
- type ErrorResponse
- type Hub
- type MapImageRequest
- type MapImageResponse
- type NewsItem
- type NewsReport
- type PollenReport
- type PollenRequest
- type QuakeReport
- type RemoveConfigRequest
- type Service
- func (service Service) DeleteCache(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetAllEvents(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetCalendar(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetConfig(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetEarthquakes(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetEvent(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetGeoForZipcode(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetMapImageForCoordinates(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetNews(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetPollen(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetSystemEndpoints(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetTimezone(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetWeather(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetWeatherAlerts(rw http.ResponseWriter, req *http.Request)
- func (service Service) GetWifiAPs(rw http.ResponseWriter, req *http.Request)
- func (service Service) SetConfig(rw http.ResponseWriter, req *http.Request)
- func (service Service) SetTimezone(rw http.ResponseWriter, req *http.Request)
- func (service Service) SetWifiConfig(rw http.ResponseWriter, req *http.Request)
- type SetConfigRequest
- type SpaHandler
- type SystemRemoteIPResponse
- type SystemResponse
- type SystemSetTimezoneRequest
- type SystemSetWifiRequest
- type WeatherDataBlock
- type WeatherDataPoint
- type WeatherReport
- type WeatherRequest
- type WsHandler
- type ZipGeoRequest
- type ZipGeoResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlertItem ¶ added in v1.0.61
type AlertItem struct { Event string `json:"event"` // Short event summary Headline string `json:"headline"` // Full headline description Description string `json:"description"` // Long description of the event Severity string `json:"severity"` // Severity of the event Urgency string `json:"urgency"` // Urgency of the event AreaDescription string `json:"area_description"` // Affected Area description Sender string `json:"sender"` // Sender (email) of the event SenderName string `json:"sendername"` // Sender name of the event Start time.Time `json:"start"` // Event start time End time.Time `json:"end"` // Event end time }
type AlertReport ¶ added in v1.0.61
type AlertReport struct { Latitude float64 `json:"latitude"` // Latitude Longitude float64 `json:"longitude"` // Longitude City string `json:"city"` // City name State string `json:"state"` // State name NWSCounty string `json:"county"` // National weather service county ActiveAlertsForCountyURL string `json:"alertsurl"` // URL to see active alerts on the NWS website for the current NWS zone Alerts []AlertItem `json:"alerts"` // Active alerts Version string `json:"version"` // Service version LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
AlertReport defines an alert report
type AlertRequest ¶ added in v1.0.61
AlertRequest represents a request to get weather alert information for the given coordiates
type CalendarItem ¶ added in v1.0.46
type CalendarRequest ¶ added in v1.0.46
CalendarRequest represents a request to get calendar information for the given iCal url and timezone
type CalendarResponse ¶ added in v1.0.46
type CalendarResponse struct { Timezone string `json:"timezone"` Currentlocaltime string `json:"currentlocaltime"` Events []CalendarItem `json:"events"` Version string `json:"version"` }
CalendarResponse represents the response from the calendar service
type CalendarView ¶ added in v1.0.51
type CalendarView struct { Items []CalendarItem `json:"items"` Timezone string `json:"timezone"` Currentlocaltime string `json:"currentlocaltime"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
CalendarView represents the data sent to the dashboard for the calendar view
type ErrorResponse ¶ added in v1.0.37
type ErrorResponse struct {
Message string `json:"message"`
}
ErrorResponse represents an API response
type Hub ¶
type Hub struct { // Inbound messages from the connections. Broadcast chan []byte // contains filtered or unexported fields }
Hub is a connection hub for websockets
type MapImageRequest ¶ added in v1.0.143
type MapImageRequest struct { Lat float64 `json:"lat"` Long float64 `json:"long"` Zoom int `json:"zoom"` }
MapImageRequest represents a request to get pollen information for the given zipcode
type MapImageResponse ¶ added in v1.0.143
type NewsItem ¶ added in v1.0.46
type NewsItem struct { ID string `json:"id"` CreateTime int64 `json:"createtime"` Text string `json:"text"` MediaURL string `json:"mediaurl"` MediaData string `json:"mediadata"` StoryURL string `json:"storyurl"` }
NewsItem represents a single news item
type NewsReport ¶ added in v1.0.46
type NewsReport struct { Items []NewsItem `json:"items"` Version string `json:"version"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
NewsReport defines a news report
type PollenReport ¶ added in v1.0.43
type PollenReport struct { Location string `json:"location"` // The location for the report Zipcode string `json:"zip"` // The zipcode for the report PredominantPollen string `json:"predominant_pollen"` // The predominant pollen in the report period StartDate time.Time `json:"startdate"` // The start time for this report Data []float64 `json:"data"` // Pollen data indices -- one for today and each future day ReportingService string `json:"service"` // The reporting service Version string `json:"version"` // Service version information LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
PollenReport represents the report of pollen data
type PollenRequest ¶ added in v1.0.43
type PollenRequest struct {
ZipCode string `json:"zipcode"`
}
PollenRequest represents a request to get pollen information for the given zipcode
type QuakeReport ¶ added in v1.0.48
type QuakeReport struct { Type string `json:"type"` Metadata struct { Generated int64 `json:"generated"` URL string `json:"url"` Title string `json:"title"` Status int `json:"status"` API string `json:"api"` Count int `json:"count"` } `json:"metadata"` Features []struct { Type string `json:"type"` Properties struct { Mag float64 `json:"mag"` // The earthquake magnitude Place string `json:"place"` // The earthquake 'place' / name Time int64 `json:"time"` // The time the earthquake event happened, in UTC Updated int64 `json:"updated"` Tz interface{} `json:"tz"` URL string `json:"url"` Detail string `json:"detail"` Felt interface{} `json:"felt"` Cdi interface{} `json:"cdi"` Mmi float64 `json:"mmi"` Alert string `json:"alert"` // The alert color (“green”, “yellow”, “orange”, “red”) this is a summary of the estimate of fatalities and economic losses Status string `json:"status"` Tsunami int `json:"tsunami"` // This flag is set to "1" for large events in oceanic regions and "0" otherwise. The existence or value of this flag does not indicate if a tsunami actually did or will exist. Sig int `json:"sig"` Net string `json:"net"` Code string `json:"code"` Ids string `json:"ids"` Sources string `json:"sources"` Types string `json:"types"` Nst interface{} `json:"nst"` Dmin float64 `json:"dmin"` Rms float64 `json:"rms"` Gap int `json:"gap"` MagType string `json:"magType"` Type string `json:"type"` Title string `json:"title"` } `json:"properties"` Geometry struct { Type string `json:"type"` Coordinates []float64 `json:"coordinates"` // Long at lat of the earthquake origin } `json:"geometry"` ID string `json:"id"` } `json:"features"` Bbox []float64 `json:"bbox"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
QuakeReport represents the report of earthquake data For a data dictionary for these fields, please see https://earthquake.usgs.gov/data/comcat/data-eventterms.php
type RemoveConfigRequest ¶ added in v1.0.39
type RemoveConfigRequest struct {
Name string `json:"name"`
}
RemoveConfigRequest represents a 'remove config' request
type Service ¶
type Service struct { DB *data.Manager StartTime time.Time HistoryTTL time.Duration // WsHub is the websocket hub connection for // broadcasting config changes to anybody interested WsHub *Hub // Cache is a runtime in-memory cache Cache *cache.Cache }
Service encapsulates API service operations
func (Service) DeleteCache ¶ added in v1.0.56
func (service Service) DeleteCache(rw http.ResponseWriter, req *http.Request)
DeleteCache godoc @Summary Removes all cached items @Description Removes all cached items @Tags cache @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /cache [delete]
func (Service) GetAllEvents ¶ added in v1.0.36
func (service Service) GetAllEvents(rw http.ResponseWriter, req *http.Request)
GetAllEvents godoc @Summary Gets all events in the system @Description Gets all events in the system @Tags events @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /events [get]
func (Service) GetCalendar ¶ added in v1.0.46
func (service Service) GetCalendar(rw http.ResponseWriter, req *http.Request)
GetCalendar godoc @Summary Gets today's calendar data for the given iCal url and timezone @Description Gets today's calendar data for the given iCal url and timezone @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/calendar [get]
func (Service) GetConfig ¶
func (service Service) GetConfig(rw http.ResponseWriter, req *http.Request)
GetConfig godoc @Summary Gets application config @Description Gets application config @Tags config @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /config [get]
func (Service) GetEarthquakes ¶ added in v1.0.48
func (service Service) GetEarthquakes(rw http.ResponseWriter, req *http.Request)
GetEarthquakes godoc @Summary Gets earthquake data for significant quakes in the last month @Description Gets earthquake data for significant quakes in the last month @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/earthquakes [get]
func (Service) GetEvent ¶ added in v1.0.36
func (service Service) GetEvent(rw http.ResponseWriter, req *http.Request)
GetEvent godoc @Summary Gets a log event. @Description Gets a log event. @Tags events @Accept json @Produce json @Param id path string true "The event id to get" @Success 200 {object} api.SystemResponse @Failure 404 {object} api.ErrorResponse @Router /event/{id} [get]
func (Service) GetGeoForZipcode ¶ added in v1.0.63
func (service Service) GetGeoForZipcode(rw http.ResponseWriter, req *http.Request)
GetGeoForZipcode godoc @Summary Gets lat/long data for the given zipcode @Description Gets lat/long data for the given zipcode @Tags dashboard @Accept json @Produce json @Param zipcode path string true "The zipcode to get lat/long informtion for" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/zipgeo/{zipcode} [get]
func (Service) GetMapImageForCoordinates ¶ added in v1.0.68
func (service Service) GetMapImageForCoordinates(rw http.ResponseWriter, req *http.Request)
GetMapImageForCoordinates godoc @Summary gets a map image for the given coordinates
func (Service) GetNews ¶ added in v1.0.46
func (service Service) GetNews(rw http.ResponseWriter, req *http.Request)
GetNews godoc @Summary Gets current breaking news, photos, and link @Description Gets current breaking news, photos, and link @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/news [get]
func (Service) GetPollen ¶ added in v1.0.43
func (service Service) GetPollen(rw http.ResponseWriter, req *http.Request)
GetPollen godoc @Summary Gets pollen data for the given zipcode @Description Gets pollen data for the given zipcode @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/pollen [get]
func (Service) GetSystemEndpoints ¶ added in v1.0.68
func (service Service) GetSystemEndpoints(rw http.ResponseWriter, req *http.Request)
GetSystemEndpoints godoc @Summary Gets the base network endpoints for the REST service and the UI @Description Gets the base network endpoints for the REST service and the UI @Tags system @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /system/endpoints [get]
func (Service) GetTimezone ¶ added in v1.0.136
func (service Service) GetTimezone(rw http.ResponseWriter, req *http.Request)
GetTimezone godoc @Summary Gets the current timezone @Description Gets the current timezone @Tags system @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /system/timezone [get]
func (Service) GetWeather ¶ added in v1.0.46
func (service Service) GetWeather(rw http.ResponseWriter, req *http.Request)
GetWeather godoc @Summary Gets weather data for the given coordinates @Description Gets weather data for the given coordinates @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/weather [get]
func (Service) GetWeatherAlerts ¶ added in v1.0.61
func (service Service) GetWeatherAlerts(rw http.ResponseWriter, req *http.Request)
GetWeatherAlerts godoc @Summary Gets weather alert data for the given coordinates @Description Gets weather alert data for the given coordinates @Tags dashboard @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 424 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /dashboard/nwsalerts [get]
func (Service) GetWifiAPs ¶ added in v1.0.82
func (service Service) GetWifiAPs(rw http.ResponseWriter, req *http.Request)
GetWifiAPs godoc @Summary Gets available nearby wifi access points, including signal strength and whether or not it's open/encrypted @Description Gets available nearby wifi access points, including signal strength and whether or not it's open/encrypted @Tags system @Accept json @Produce json @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /system/wifiaps [get]
func (Service) SetConfig ¶
func (service Service) SetConfig(rw http.ResponseWriter, req *http.Request)
SetConfig godoc @Summary Sets system config item(s) and broadcasts the change on the websocket @Description Sets system config item(s) and broadcasts the change on the websocket @Tags config @Accept json @Produce json @Param config body data.SystemConfig true "The config data to update" @Success 200 {object} api.SystemResponse @Failure 400 {object} api.ErrorResponse @Failure 500 {object} api.ErrorResponse @Router /config [post]
func (Service) SetTimezone ¶ added in v1.0.136
func (service Service) SetTimezone(rw http.ResponseWriter, req *http.Request)
SetTimezone godoc @Summary Sets the timezone @Description Sets the timezone @Tags system @Accept json @Produce json @Param wifiap body api.SystemSetTimezoneRequest true "The timezone to use" @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /system/timezone [post]
func (Service) SetWifiConfig ¶ added in v1.0.114
func (service Service) SetWifiConfig(rw http.ResponseWriter, req *http.Request)
SetWifiConfig godoc @Summary Sets the default Wifi network to use @Description Sets the default Wifi network to use @Tags system @Accept json @Produce json @Param wifiap body api.SystemSetWifiRequest true "The wifi settings to use" @Success 200 {object} api.SystemResponse @Failure 500 {object} api.ErrorResponse @Router /system/wifiap [post]
type SetConfigRequest ¶ added in v1.0.39
SetConfigRequest represents a 'set config' request
type SpaHandler ¶ added in v1.0.41
SpaHandler implements the http.Handler interface, so we can use it to respond to HTTP requests. The path to the static directory and path to the index file within that static directory are used to serve the SPA in the given static directory.
func (SpaHandler) ServeHTTP ¶ added in v1.0.41
func (h SpaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP inspects the URL path to locate a file within the static dir on the SPA handler. If a file is found, it will be served. If not, the file located at the index path on the SPA handler will be served. This is suitable behavior for serving an SPA (single page application).
type SystemRemoteIPResponse ¶ added in v1.0.68
type SystemRemoteIPResponse struct { ServiceEndpoint string `json:"service"` UIEndpoint string `json:"ui"` }
SystemRemoteIPResponse represents a response to GetRemoteIP
type SystemResponse ¶
type SystemResponse struct { Message string `json:"message"` Data interface{} `json:"data"` }
SystemResponse is a response for a system request
type SystemSetTimezoneRequest ¶ added in v1.0.144
type SystemSetTimezoneRequest struct {
Timezone string `json:"timezone"`
}
SystemSetTimezoneRequest represents a request to set the current timezone
type SystemSetWifiRequest ¶ added in v1.0.114
SystemSetWifiRequest represents a request to set the current wifi network
type WeatherDataBlock ¶ added in v1.0.46
type WeatherDataBlock struct { Summary string `json:"summary"` Icon string `json:"icon"` Data []WeatherDataPoint `json:"data"` }
WeatherDataBlock defines a group of data points
type WeatherDataPoint ¶ added in v1.0.46
type WeatherDataPoint struct { Time int64 `json:"time"` Summary string `json:"summary"` Icon string `json:"icon"` PrecipIntensity float64 `json:"precipIntensity"` PrecipIntensityMax float64 `json:"precipIntensityMax"` PrecipProbability float64 `json:"precipProbability"` PrecipType string `json:"precipType"` PrecipAccumulation float64 `json:"precipAccumulation"` Temperature float64 `json:"temperature"` TemperatureMin float64 `json:"temperatureMin"` TemperatureMax float64 `json:"temperatureMax"` ApparentTemperature float64 `json:"apparentTemperature"` WindSpeed float64 `json:"windSpeed"` WindGust float64 `json:"windGust"` WindBearing float64 `json:"windBearing"` CloudCover float64 `json:"cloudCover"` Humidity float64 `json:"humidity"` Pressure float64 `json:"pressure"` Visibility float64 `json:"visibility"` Ozone float64 `json:"ozone"` UVIndex float64 `json:"uvindex"` }
WeatherDataPoint defines a weather data point
type WeatherReport ¶ added in v1.0.46
type WeatherReport struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Currently WeatherDataPoint `json:"currently"` Daily WeatherDataBlock `json:"daily"` Hourly []WeatherDataPoint `json:"hourly"` APICalls int `json:"apicalls"` Code int `json:"code"` Version string `json:"version"` LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
WeatherReport defines a weather report
type WeatherRequest ¶ added in v1.0.46
WeatherRequest represents a request to get weather information for the given coordiates
type ZipGeoRequest ¶ added in v1.0.63
type ZipGeoRequest struct {
Zipcode string `json:"zipcode"`
}
ZipGeoRequest represents a request to the zipgeo service
type ZipGeoResponse ¶ added in v1.0.63
type ZipGeoResponse struct { Zipcode int `json:"zipcode"` // US zipcode Latitude float64 `json:"latitude"` // Latitude Longitude float64 `json:"longitude"` // Longitude Version string `json:"version"` // Service version LastFetched time.Time `json:"last_fetched"` // The last time the data was fetched Cached bool `json:"cached"` // 'true' if this data was fetched from cache }
ZipGeo defines a zipcode -> lat,long lookup result