webservice

package
v0.0.0-...-161b4be Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	HTTPCode int    `json:"-"`
	Code     int    `json:"code,omitempty"`
	Message  string `json:"message"`
}

APIError is the error returned to clients whenever an internal error has happened.

type APIVehicle

type APIVehicle struct {
	Hash         string `json:"hash"`
	Country      string `json:"country"`
	Type         string `json:"type"`
	RegNr        string `json:"regNr"`
	VIN          string `json:"vin"`
	Brand        string `json:"brand"`
	Model        string `json:"model"`
	Variant      string `json:"variant"`
	FuelType     string `json:"fuelType"`
	FirstRegDate string `json:"firstRegDate"`
	FromCache    bool   `json:"fromCache"`
}

APIVehicle is the API representation of Vehicle. It has a JSON representation. Some fields that are only for internal use, are left out, and others are converted into something more readable.

type WebServer

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

WebServer represents the REST-API part of autobot.

func New

func New(store *vehicle.Store, mngr *extlookup.Manager, cnf config.Config) *WebServer

New initialises a new webserver. You need to start it by calling Serve().

func (*WebServer) JSONError

func (srv *WebServer) JSONError(w http.ResponseWriter, handlerErr APIError)

JSONError serves the given error as JSON.

func (*WebServer) Serve

func (srv *WebServer) Serve(port uint, sync bool) error

Serve starts the web server. It never returns unless interrupted.

Jump to

Keyboard shortcuts

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