api

package
v0.0.0-...-10cf1ec Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API implements a simple HTTP API server to expose Car data.

func New

func New(engine *sdk.OPA) *API

New returns a instance of the API.

func (*API) Run

func (api *API) Run(context.Context) error

Run starts the HTTP server.

type Car

type Car struct {
	ID        string `json:"id"`
	Model     string `json:"model"`
	VehicleID string `json:"vehicle_id"`
	OwnerID   string `json:"owner_id"`
}

Car represents a car managed by the service.

type CarPosition

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

CarPosition defines the coordinates of the car.

type CarStatus

type CarStatus struct {
	ID       string      `json:"id"`
	Position CarPosition `json:"position"`
	Mileage  int         `json:"mileage"`
	Speed    int         `json:"speed"`
	Fuel     float64     `json:"fuel"`
}

CarStatus represents the status of a car managed by the service.

type DB

type DB struct {
	Cars     map[string]Car
	Statuses map[string]CarStatus
}

DB represents an instance of the service's database.

Jump to

Keyboard shortcuts

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