api

package
v0.0.0-...-4d2a565 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package api provides the common resources for go chi API handlers and routers for the State Server API, namely error responses and RFC 7946 GeoJSON schema structs for serializing and deserializing JSON

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequestError

func BadRequestError(err error) render.Renderer

creates the go-chi renderer for HTTP 400 responses

func InternalServerError

func InternalServerError(err error) render.Renderer

creates the go-chi renderer for HTTP 500 responses

func NotFoundError

func NotFoundError(err error) render.Renderer

creates the go-chi renderer for HTTP 404 responses

Types

type ErrorResponse

type ErrorResponse struct {
	Err            error  `json:"-"`
	StatusText     string `json:"status"`
	ErrorText      string `json:"error,omitempty"`
	HTTPStatusCode int    `json:"-"`
}

Schema for any non-200 HTTP response

func (*ErrorResponse) Render

render method which hooks into the go-chi renderer and ensures the correct HTTP response status code is writtern to the response

type Feature

type Feature struct {
	Type       string     `json:"type"`
	Properties Properties `json:"properties"`
	Geometry   Geometry   `json:"geometry"`
}

GeoJSON schema for a feature object

func (Feature) Render

func (sr Feature) Render(w http.ResponseWriter, r *http.Request) error

render method which hooks into the go-chi renderer

type FeatureCollection

type FeatureCollection struct {
	Type     string    `json:"type"`
	Features []Feature `json:"features"`
}

GeoJSON schema for a FeatureCollection object to represent a collection of several states

func (FeatureCollection) Render

type Geometry

type Geometry struct {
	Type        string                    `json:"type"`
	Coordinates [][]geospatial.Coordinate `json:"coordinates"`
}

GeoJSON schema for the geometry object of a feature

type Properties

type Properties struct {
	State string `json:"state"`
}

GeoJSON schema for the properties object of a feature

Directories

Path Synopsis
Package backend provides an in-memory thread-safe data store for creating and accessing [geospatial.State] objects.
Package backend provides an in-memory thread-safe data store for creating and accessing [geospatial.State] objects.
Package location provides the router and handler for the State Server endpoint which finds the state(s) in which a given location is contained
Package location provides the router and handler for the State Server endpoint which finds the state(s) in which a given location is contained
Package states provides the REST API endpoints needed for CRUD operations on geospatial state objects in the backend data store
Package states provides the REST API endpoints needed for CRUD operations on geospatial state objects in the backend data store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL