weather

package
v0.0.0-...-dd7b5e9 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Client

type Client interface {
	CurrentWeatherAtLocation(ctx context.Context, lattitude float64, longitude float64) (WeatherData, error)
}

type Handler

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

func NewHandler

func NewHandler(logger *slog.Logger, service Service) Handler

func (Handler) GetWeather

func (h Handler) GetWeather(w http.ResponseWriter, r *http.Request)

type Service

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

func NewService

func NewService(weatherClient openweather.Client) Service

func (Service) GetCurrentWeather

func (s Service) GetCurrentWeather(ctx context.Context, logger *slog.Logger, unitType UnitType, latitude float64, longitude float64) (WeatherData, error)

type TemperatureType

type TemperatureType string
const (
	TemperatureTypeHot      TemperatureType = "hot"
	TemperatureTypeCold     TemperatureType = "cold"
	TemperatureTypeModerate TemperatureType = "moderate"
)

type UnitType

type UnitType string
const (
	UnitTypeScientific UnitType = "scientific"
	UnitTypeImperial   UnitType = "imperial"
	UnitTypeMetric     UnitType = "metric"
)

type WeatherData

type WeatherData struct {
	Temperature     float64         `json:"temperature"`
	UnitType        UnitType        `json:"unit_type"`
	Conditions      []string        `json:"conditions"`
	TemperatureType TemperatureType `json:"temperature_type"`
}

Jump to

Keyboard shortcuts

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