api

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxHistory = 30

MaxHistory variable determines the maximum number of data points that will be saved for each service station in the database.

View Source
var Refresh = 30 * time.Minute

Refresh is a variable that determines how often the gas price data is fetched from the French government API.

Functions

This section is empty.

Types

type API

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

API structure is the container for the fetched gas price data from the French government. It holds information such as the current price, the date and time of the latest update, and any other relevant metadata. This structure is used by the application to access and manipulate the gas price data.

func Start

func Start(l *log.Logger, path string) (*API, error)

The Start function initializes an instance of the API structure and launches a goroutine to periodically refresh the gas price data from the French government API. This function takes in a logger to log any relevant information or errors and a path to the database to store the fetched data. Once called, the Start function will continue to run in the background, periodically refreshing the gas price data and storing it in the specified database. The initialized API instance is returned by this function and can be used by the application to access and manipulate the gas price data. Stop may be called to kill the launched goroutine.

func (*API) Handler

func (a *API) Handler() http.Handler

The Handler function returns an http.Handler that can be used with the http package to handle incoming HTTP requests. The Handler function allows the application to expose the fetched gas price data over a network via HTTP and can be used to build a simple RESTful API for the gas price data."

func (*API) ServeHTTP

func (a *API) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*API) Stop

func (a *API) Stop()

Stop kills the goroutine instanced in Start.

type Result

type Result struct {
	Distance float32 `json:"distance"`
	gas.Data
}

Jump to

Keyboard shortcuts

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