utils

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorLogger = log.New(os.Stdout, "ERROR: ", log.LUTC|log.Ltime|log.Lshortfile)
)

Functions

func ComputeForecasts

func ComputeForecasts(forecasts *models.Forecasts, openDataForecasts models.OpenDataAPIResponse)

Populate a []models.Forecast pointer with the OpenAPI data

func ComputeMetadaLinks(itemCount int, limit int, offset int, path string) []interface{}

Create the metadalinks associated to the response

func FormatDataTime

func FormatDataTime(
	stringTime string,
	closingDate string,
	offsetInSec int,
	location time.Location,
) (time.Time, error)

Take the date, the hours and the timezone offset and return the related time.Time object

func GetIntParams

func GetIntParams(c *gin.Context, paramName string) (int, error)

Get the int param paramName passed into the request. Return an erro if not specified or empty, the value either

func GetOpenAPIData

func GetOpenAPIData(openDataAPIResponse *models.OpenDataAPIResponse) error

Get forecasts data from the Opendata API Populate the *models.OpenDataAPIResponse pointer if the data are correct

func GetStringParams

func GetStringParams(c *gin.Context, paramName string) string

Get the string param paramName passed into the request. Return empty string if not specified or empty, the value either

func GetTimezoneFromHeader

func GetTimezoneFromHeader(c *gin.Context) (*time.Location, error)

Get the timezone passed into the request header. Return an error if the header is missing and/or malformated. The value either

func JsonLoggerMiddleware

func JsonLoggerMiddleware() gin.HandlerFunc

func MapBoats

func MapBoats(
	closingReason models.ClosingReason,
	boatNames string,
	closingDuration time.Duration,
	circulationClosingDate time.Time,
	alreadySeenBoatNames *[]string,
	forecastID string,
) []models.Boat

Return a []models.Boat of a boat crossing forecast. closingReason : If it is a maintenance forecast, no computation boatNames : The raw string containing the boat name(s) closingDuration : Used to compute the approximated crossing time circulationClosingDate : Used to compute the approximated crossing time alreadySeenBoatNames : Array pointer to keep track of the boats. Used to compute the boat Maneuver forecastID : Used to compute the "self" link

func MapClosingReason

func MapClosingReason(stringClosingReason string) models.ClosingReason

Return the corresponding models.ClosingReason according of the string value

func MapClosingType

func MapClosingType(stringClosingType string) models.ClosingType

Return the corresponding models.ClosingType according of the string value

Types

This section is empty.

Jump to

Keyboard shortcuts

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