location

package
v0.1.0-alpha9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package location provides the full application stack for location data. Including transport & querying.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTP

type HTTP struct {
	// contains filtered or unexported fields
}

The HTTP type contains HTTP request handlers that serve location data.

func NewHTTP

func NewHTTP(location Repository) *HTTP

NewHTTP returns a new instance of the HTTP type that will serve location data queried from the Repository implementation.

func (*HTTP) Latest

func (h *HTTP) Latest(w http.ResponseWriter, r *http.Request)

Latest handles an inbound HTTP GET request that returns the latest location stored within the Repository.

func (*HTTP) Register

func (h *HTTP) Register(router *mux.Router)

Register the HTTP routes into the given router.

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

The Location type describes a point on the globe as a latitude and longitude.

type PostgresRepository

type PostgresRepository struct {
	// contains filtered or unexported fields
}

func NewPostgresRepository

func NewPostgresRepository(db *sql.DB) *PostgresRepository

NewPostgresRepository returns a new instance of the PostgresRepository type that will perform queries against the provided sql.DB instance.

func (*PostgresRepository) Latest

func (r *PostgresRepository) Latest(ctx context.Context) (Location, error)

Latest returns the most recent location data stored within the database.

type Repository

type Repository interface {
	Latest(ctx context.Context) (Location, error)
}

The Repository interface describes types that can query location database from persistent storage.

Jump to

Keyboard shortcuts

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