Documentation ¶
Overview ¶
Package state-server is the State Server REST API HTTP server. It uses the go-chi framework to handle http requests to get the state (or states) in which a location is contained, render the state location data as JSON in the [RFC 7946 GeoJSON] format, render the full collection of states, create a state, or delete a state.
Example requests ¶
Get the state(s), if any, in which a location exists:
$ curl -d "longitude=-77.036133&latitude=40.513799" http://localhost:8080/ ["Pennsylvania"] $ curl -d "longitude=-77.036133&latitude=45" http://localhost:8080/ {"status":"Not Found","error":"[-77.036133, 45] not within any state"}
Get the GeoJSON Feature object which contains the location data for Pennsylvania
$ curl http://localhost:8080/api/v1/state/pennsylvania "type":"Feature","properties":{"state":"Pennsylvania"},"geometry":{"type":"Polygon","coordinates":[[[-77.475793,39.719623],..., ]]}}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
func LoadConfig() (serverConfig, error)
func StateServerAPIRouter ¶
func StateServerAPIRouter(store StateLocationDataProvider) *chi.Mux
Types ¶
type StateLocationDataProvider ¶
type StateLocationDataProvider interface { GetAll() ([]geospatial.State, error) GetByName(name string) (geospatial.State, error) Create(geospatial.State) (geospatial.State, error) Delete(name string) error }
type StateServer ¶
type StateServer struct {
// contains filtered or unexported fields
}
func NewStateServer ¶
func NewStateServer(config serverConfig, store StateLocationDataProvider) *StateServer
Click to show internal directories.
Click to hide internal directories.